Skip to Content
Technical Articles
Author's profile photo Stefan Schnell

Process Synchronisation Between ABAP and the Presentation Server

The overview of this forum offers a lot of connection technologies from and to ABAP, e.g. HTTP, XML and SOAP, RFC/BAPI etc. etc. etc. I am the opinion, that the COM interface (Component Object Model) is also a connection technology of ABAP. Sure, it works only with dialog processes with the SAP GUI for Windows, on this point it is limited in comparison with other connectivity methods. Last but not least combines the ABAP COM interface an easy coding with powerful possibilities.

Here now an example of process synchronisation between ABAP and the Microsoft Office suite, e.g. Excel with VBA (Visual Basic for Applications), via a COM library. For the process synchronization and communication offers Windows the IPC interface (Interprocess Communication).

There are different technics to synchronize and to communicate between processes on Windows, like

  • Events,
  • Semaphores,
  • FileMaps and
  • the ClipBoard
  • etc.

To use this possibilities I programmed a COM library which offers this technics. You find it here.

At first the ABAP program which creates an event, with the name TestEvent, and then it waits until the event is set.


  Report  zCOMIPC.


    Include OLE2INCL.


    Constants Infinite Type i Value -1.


    Data oIPC Type Ole2_Object.

    Data rc Type i.

    Data hEvent Type i.


    Create Object oIPC ‘COMIPC’.

    If sy-subrc = 0 And oIPC-HANDLE <> 0 And oIPC-TYPE = ‘OLE2’.


        Call Method Of oIPC ‘EventCreate’ = hEvent

          Exporting #1 = ‘TestEvent’ #2 = 1 #3 = 0.

        Call Function ‘AC_SYSTEM_FLUSH’ Exceptions Others = 1.


        If hEvent <> 0.

          Call Method Of oIPC ‘EventWait’ = rc

            Exporting #1 = ‘TestEvent’ #2 = Infinite.



          “- At this point the ABAP program waits until the VBA routine

          “- was executed



          Call Function ‘AC_SYSTEM_FLUSH’ Exceptions Others = 1.

          Call Method Of oIPC ‘EventClose’ = rc

            Exporting #1 = hEvent.

          Call Function ‘AC_SYSTEM_FLUSH’ Exceptions Others = 1.



      Free Object oIPC.



Here now the VBA routine, to set the event.



  ‘-Sub TestEvent——————————————————-

    Sub TestEvent()


      Set oIPC = CreateObject(“COMIPC”)


      oIPC.EVENTSET “TestEvent”


      Set oIPC = Nothing


    End Sub


After the event is set, the ABAP program continues running and closes the event.

This simple example should demonstrate, on the one hand, that with little effort very interesting solutions can be created and, on the other hand, how powerful these solutions can be. On this way you can synchronize now different processes on the application and presentation server, in a context of dialog processes. The example above could be used to get data from ABAP to the Office suite, the data could be processed, in a longer running process, and after this the data comes back to the same ABAP process, which continues its work. Certainly there are many ways to realize this, and this is one of them.

The COM library itself is nothing more than an easy wrapper around the Windows API functions of IPC. Here as example the EventSet method:



‘- Sets the specified event object to the signaled state


‘- Param: EventName As String

‘- Return: Zero if fails



  Method EventSet(ByVal EventName As String) As Long


      Local NameOfEvent As AsciiZ * %Max_Path

      Local hEvent As Dword

      Local resSet As Long

      Local resClose As Long

    NameOfEvent = ACode$(EventName)

    hEvent = OpenEvent(%EVENT_ALL_ACCESS, 0, NameOfEvent)

    If hEvent Then

      ‘-Set event——————————————————-

        resSet = SetEvent(hEvent)

      ‘-Close handle—————————————————-

        resClose = CloseHandle(hEvent)


        If resSet And resClose Then

          Method = resSet


          Method = 0

        End If


      Method = 0

    End If

  End Method

You can realize it in any programming language which supports COM library creation.

Hope you enjoy the perspective.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.