7 Replies Latest reply: Jul 17, 2013 8:36 AM by MIke Drozdov RSS

Register and use custom .NET DLL functions in ABAP

kholoud Yehia
Currently Being Moderated

Dear All,

 

I have a requirment in my implementation to use a custom DLL functions in my ABAP program? Could anyone tell me how i can use that DLL in my ABAP program?

 

 

Thanks

  • Re: Register and use custom .NET DLL functions in ABAP
    Case Ahr
    Currently Being Moderated
    • On the "Compile" tab of the .NET project properties, check the box for "Register for COM interop." 
    • Install the library on your local machine or whatever machine needs to access the DLL. 
    • Register the object in SAP in transaction SOLE.
    • Call it like this in ABAP:

     

     

    TYPE-POOLS  ole2.

    DATA: mydll type ole2_object,
          str   type string VALUE 'Empty'.

       CREATE OBJECT mydll 'MYAPP.LAUNCH'.

       IF mydll-handle > 0.

         CALL METHOD OF mydll 'GetText' = str.

       ENDIF.

       WRITE str.

     

    Email me if you'd like a copy of the .NET code.

    • Re: Register and use custom .NET DLL functions in ABAP
      Kemal Tsani
      Currently Being Moderated

      hai case, i've problem when register and use custome .NET dll, i've followed the instructions you gave but still no hope, sy-subrc = 2 when call method.

      Can u give me copy of the .NET code? and where i can get CLSID when register the object in SAP in transaction SOLE? i already install the library on my local machine.

       

      Thanks before.

      Regards,

      Kemal

      • Re: Register and use custom .NET DLL functions in ABAP
        Case Ahr
        Currently Being Moderated

        You can generate your own ID using Tools --> Create GUID.  It resides in the implementation object in the .NET project.

         

        Here is what my interface object looks like (VB.NET):

         

        Imports System
        Imports System.Text
        Imports System.Runtime.InteropServices

        Namespace HESwipeAx

            <ComVisible(True)> <InterfaceType(ComInterfaceType.InterfaceIsDual)> <Guid("BD8D4391-DBF4-4633-938B-F94281DC8D9D")> _
            Public Interface ILaunch

                Function GetText() As String


            End Interface
        End Namespace

         

        And my implementation looks like this.  I've highlighted the CLSID.

         

        Imports System.Runtime.InteropServices

        Namespace HESwipeAx
            <ComVisible(True)> _
            <ClassInterface(ClassInterfaceType.None)> _
            <Guid("014320CD-0448-4161-9629-1E3DCA3C6452")> _
            <ProgId("HESwipeAx.Launch")> _
            <ComDefaultInterface(GetType(ILaunch))> _
            Public Class Launch
                Inherits UserControl
                Implements ILaunch, IObjectSafety

         

                Public Function GetText() As String Implements ILaunch.GetText
                    Dim prompt As New MainForm
                    If prompt.ShowDialog = DialogResult.OK Then
                        Return prompt.textReturnVal.Text
                    Else
                        Return String.Empty
                    End If

                             HERE IS THE MAIN METHOD -- return what you want in this function.
                End Function

                Public Function GetInterfaceSafetyOptions(ByRef riid As System.Guid, ByRef pdwSupportedOptions As Integer, ByRef pdwEnabledOptions As Integer) As Integer Implements IObjectSafety.GetInterfaceSafetyOptions
                    Dim m_options As ObjectSafetyOptions = ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_CALLER Or ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_DATA
                    pdwSupportedOptions = CInt(m_options)
                    pdwEnabledOptions = CInt(m_options)
                    Return 0
                End Function

                Public Function SetInterfaceSafetyOptions(ByRef riid As System.Guid, dwOptionSetMask As Integer, dwEnabledOptions As Integer) As Integer Implements IObjectSafety.SetInterfaceSafetyOptions
                    Return 0

                End Function

                Public Enum ObjectSafetyOptions
                    INTERFACESAFE_FOR_UNTRUSTED_CALLER = &H1
                    INTERFACESAFE_FOR_UNTRUSTED_DATA = &H2
                    INTERFACE_USES_DISPEX = &H4
                    INTERFACE_USES_SECURITY_MANAGER = &H8
                End Enum

            End Class
        End Namespace

         

        Hope that helps.

Actions