In ABAP language exists many forms to connect and i want explain how to call dll files for Windows
Below follow step by step to construction:
1 – Create the dll files. In my example i am using the visual basic language, but you can use another language of programmer (ex.: Delphi, C# etc)
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "DLL_VB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Declaration of variable return
Private s_retorno As String
Public Property Get retorno() As String
retorno = "retorno: " & s_retorno
End Property
' Function that receives the command and variable playing in s_retorno
Public Function envia_comando(ByRef s_comando As String)
s_retorno = s_comando
End Function
1.1 - Afterbuilding the DLLyou need to registerin windows using the command:
regsvr32 <file name >.dll
After this you are should look the pop-up with message:
2 - Execute the program regedit.exe in Windows System and find the name of DLL file
You need find two values in regedit.exe.
CLsid : {2EC47E73-2E05-45BA-AC8B-CD7E798D4034}
TypeLib: {4F4B5B12-5F45-43DB-A06E-2065395F9866}
3 - This values do you must put in transaction SOLE
4 - Below the example in SAP ABAP that call dll file in Windows.
This example: send a string and return another string using the file dll
*"----------------------------------------------------------------------
*"*"Interface local:
*" IMPORTING
*" VALUE(I_COMANDO) TYPE CHAR20 OPTIONAL
*" EXPORTING
*" VALUE(E_RETORNO) TYPE CHAR20
*" EXCEPTIONS
*" CREATE_OBJECT_ERROR
*" GET_PROPR_ERROR
*" CALL_ERROR
*" FREE_OBJ_ERROR
*"----------------------------------------------------------------------
* Includes
INCLUDE ole2incl.
* Global Variables
DATA: obj_vb TYPE ole2_object,
vg_comando(20) TYPE c,
vg_retorno(20) TYPE c.
* sends the command to the dll
vg_comando = I_COMANDO.
* Creating the object to use the DLL
CREATE OBJECT obj_vb 'TESTDLL'.
IF sy-subrc NE 0.
RAISE create_object_error.
ENDIF.
* Sending the command to the dll
CALL METHOD OF obj_vb 'envia_comando' EXPORTING #1 = vg_comando.
* Receiving command of dll
get property of obj_vb 'RETORNO' = vg_retorno.
IF sy-subrc NE 0.
RAISE get_propr_error.
ELSE.
E_RETORNO = vg_retorno.
ENDIF.
* Deallocates the object memory
FREE OBJECT obj_vb.
IF sy-subrc NE 0.
RAISE free_obj_error.
ENDIF.
ENDFUNCTION.
I have helped, any questions please send a message.
Regards
Marcelo Macedo