Skip to Content

How to call DLL functions from the client in ABAP programs

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.

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

  • OLE Application: DynamicWrapperX
  • CLSID: {89565275-A714-4a43-912E-978B935EDCCC}
  • CLSID Type Lib: {89565275-A714-4a43-912E-978B935EDCCC}
  • OLE-Objectname: DynamicWrapperX
  • Language: EN
  • Text: 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:


      IDNo TYPE i VALUE 7.

      ret TYPE i.

CREATE OBJECT Win32 'DynamicWrapperX'.

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

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

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


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

Enjoy the possibilities.

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Posted on Oct 25, 2010 at 03:15 PM

    Thanks for sharing, please create an entry in the ABAP section of the SDN wiki with this information.


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2012 at 12:12 PM

    Thanks a lot!

    Can you show example, when METHOD has to return the value.

    For example: I need to use some AddInISC.dll.

    it works whith VB in our project like this:

    Set DX = CreateObject("DynamicWrapperX")

    DX.Register "AddInISC.dll", "CalcRic"

    _value = DX.CalcRic( "MANYSYMBOLS", 0)

    now _value has data.

    How do use this example in ABAP?

    I try to use as in your example, but ... I don't understand where I do mistake.

    CREATE OBJECT Win32 'DynamicWrapperX'.

    CALL METHOD OF Win32 'Register'
    #1 = 'C:\WINDOWS\system\AddInISC.dll' #2 = 'CalcRic'.

    CALL METHOD OF Win32 'CalcRic'
    #1 = 'MANYSYMBOLS' #2 = 0.

    GET PROPERTY OF Win32 'CalcRic' = cik.

    WRITE: cik. " nothing here.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Stefan Schnell


      Thank you very much for your attention and help.

      However it doesn't work, despite that was made as ActivX kind. Perhaps, author of that "dll" made it

      not correctly.

      I leave it for later temporary.



  • Posted on Dec 26, 2013 at 03:05 PM

    Hi Stefan,


    need your help for one of my requirement, mentioned below.Any help from you would be higly appriciated.

    We have got requirement to call DLL functions from SAP for POS device(Point of Sale i.e Card swipe machine during Payment).

    Here POS device has certain functions like api_CheckExistance, api_TriggerTrxTrack2 and api_GetTransactionResult to use POS. we tried to implement the same methods by using above approach that you mentioned, but could not success. Could you please let us know, how to handle POS device functions, especially importing parameter?

    Example : Below function need to call in SAP

    Function Name:


    Function Usage:

    Can be used to read the Terminal Identification Number and Retailer Identification Number from the terminal’s Non- volatile configuration memory for the host application’s internal purposes.

    One common use of it is to stamp the transaction with the terminal ID that processed the transaction.

    Input Parameter:


    Return Parameter:

    The function requires two parameters, which will be filled with appropriate data.

    1. 1. szTerminalID: This parameter should be at least 9 bytes long as the terminal ID size is always eight digits and the library appends a null character at the end for “C” specific null termination.
    2. 2. szRetailerID: should be at least 17 bytes long as the retailer ID could be a maximum of 16 characters, if the retailer ID is smaller than 16 characters, spaces are appended at the end to retain the 16 byte boundary.

    Function Declaration in C++:

    extern "C" int FAR PASCAL EXPORT api_GetTerminalParams(char FAR *szTerminalID, char FAR *szRetailerID);

    An example C++ code is present in the C++ project source supplied along with this document

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Harjyot,

      I expand the Pointer for COM (P4COM) library. Now it is also possible to call functions in a dynamic link library - not so comfortable but it works.

      Here an example:


      Program zPointOfSale.

      "-Type Pools--------------------------------------------

      Type-Pools OLE2.


      Data Ptr Type OLE2_OBJECT.

      Data TerminalID Type String Value ''.

      Data ptrTerminalID Type i Value 0.

      Data RetailerID Type String Value ''.

      Data ptrRetailerID Type i Value 0.

      Data hDLL Type i Value 0.

      Data Vars Type i Value 0.

      Data ret Type i Value 0.


      Create Object Ptr 'P4Com'.

      If sy-subrc = 0 And Ptr-Handle <> 0 And

      Ptr-Type = 'OLE2'.

      "-Create variables in memory------------------------

      Call Method Of Ptr 'CreateVar' = ptrTerminalID

      Exporting #1 = 'TerminalID' #2 = 'String'

      #3 = 9.

      Call Method Of Ptr 'CreateVar' = ptrRetailerID

      Exporting #1 = 'RetailerID' #2 = 'String'

      #3 = 17.

      "-Open the library----------------------------------

      Call Method Of Ptr 'OpenLibrary' = hDLL

      Exporting #1 = 'C:\Dummy\POS.dll'.

      If hDLL <> 0 And ptrTerminalID <> 0 And

      ptrRetailerID <> 0.

      "-Create stack for function call------------------

      Call Method Of Ptr 'CreateVar' = Vars

      Exporting #1 = 'Vars' #2 = 'Array' #3 = 8.

      If Vars <> 0.

      "-Push variables on the stack-------------------


      " Hint: It is in reverse order, because it is

      " Pascal calling convention



      Call Method Of Ptr 'SetArrayLong'

      Exporting #1 = 'Vars' #2 = 0

      #3 = ptrRetailerID.

      Call Method Of Ptr 'SetArrayLong'

      Exporting #1 = 'Vars' #2 = 4

      #3 = ptrTerminalID.

      "-Call the function in the library--------------

      Call Method Of Ptr 'CallFunction' = ret

      Exporting #1 = hDLL


      #3 = 2 #4 = Vars.

      "-Get result------------------------------------

      Call Method Of Ptr 'GetStringVar' = TerminalID

      Exporting #1 = 'TerminalID'.

      Call Method Of Ptr 'GetStringVar' = RetailerID

      Exporting #1 = 'RetailerID'.

      "-Destroy stack---------------------------------

      Call Method Of Ptr 'DestroyVar' = ret

      Exporting #1 = 'Vars'.


      "-Destroy variables-------------------------------

      Call Method Of Ptr 'DestroyVar' = ret

      Exporting #1 = 'RetailerID'.

      Call Method Of Ptr 'DestroyVar' = ret

      Exporting #1 = 'TerminalID'.

      "-Close the library-------------------------------

      Call Method Of Ptr 'CloseLibrary' = ret

      Exporting #1 = hDLL.


      Write: / TerminalID.

      Write: / RetailerID.

      Free Object Ptr.





  • Posted on Jan 23, 2014 at 06:59 PM

    Hi Stefan,

    Please check the link How to call a dll file of windows using SAP ABAP


    Marcelo Macedo

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 13 at 02:48 PM

    Unfortunately, the DLL of DynamicWrapperX was put into quarantine by Windows Security because of threat HackTool:Win32/Daoak.A, so unfortunately I can't/must not use it on my professional laptop.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.