Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to call DLL functions from the client in ABAP programs

Hello community,

it is not ordinary but very easy to use DLL calls in ABAP language. Yuri Popov programmed a module, called DynamicWrapperX. It is an ActiveX component, which allow to call each function in a DLL you want via COM. A great module, you find the module [here|http://www.script-coding.info/dynwrapx_eng.html].

It is necessary before, with the transaction code SOLE, register the OLE application DynamicWrapperX in the SAP system. Type in:

u2022OLE Application: DynamicWrapperX

u2022CLSID: {89565275-A714-4a43-912E-978B935EDCCC}

u2022CLSID Type Lib: {89565275-A714-4a43-912E-978B935EDCCC}

u2022OLE-Objectname: DynamicWrapperX

u2022Language: EN

u2022Text: Component allows to call functions exported by DLLs

And it is necessary to register DynamicWrapperX on the client system too, with regsvr32.exe dynwrapx.dll.

Look at the following example how easy it is to use a Windows function from USER32.DLL:

  INCLUDE OLE2INCL.

  "-Constants------------------------------
    DATA IDYes TYPE i VALUE 6.
    DATA IDNo TYPE i VALUE 7.

  "-Variables------------------------------
    DATA Win32 TYPE OLE2_OBJECT.
    DATA ret TYPE i.

  CREATE OBJECT Win32 'DynamicWrapperX'.

  CALL METHOD OF Win32 'Register' EXPORTING
    #1 = 'user32.dll' #2 = 'MessageBoxW'
    #3 = 'i=hwwu' #4 = 'r=l'.

  CALL METHOD OF Win32 'MessageBoxW' = ret
    EXPORTING #1 = 0 #2 = 'Hello World'
    #3 = 'Test' #4 = 4.

  IF ret = IDYes.
    WRITE 'Ja'.
  ELSEIF ret = IDNo.
    WRITE 'Nein'.
  ELSE.
    WRITE '?'.
  ENDIF.

  FREE OBJECT Win32.

Important hint: This method works only with foreground jobs and online processes and not with background jobs and batch processes.

Enjoy the possibilities.

Cheers

Stefan

Edited by: Stefan Schnell on Oct 25, 2010 5:02 PM

Not what you were looking for? View more on this topic or Ask a question