Skip to Content
Former Member
Feb 14, 2012 at 03:49 PM

SAPGUI Scripting - Connection in Delphi/Lazarus



i tried to convert my autoitscript projects to Delphi/Lazarus because i need a few things autoit can´t offer. I have a few scripts written that interact with the SAP GUI that work quite well, e.g. Excel data import, specific label printing (p-touch) automated data change/correction etc.

I thought the simple connection to the SAP-GUI scripting wouldn´t be that difficult to migrate but in fact i´m not able to just do the simple task to connect to the running SAP session in Delphi/Lazarus.

Perhaps anyone has already done this and could share the code in Delphi/Lazarus that does the following that works perfectly well in Visual Studio VBA:

Dim sapgui, sapapp, sap_connection, sap_session As Object

        sapgui = GetObject("SAPGUI")
        sapapp = sapgui.GetScriptingEngine
        sap_connection = sapapp.Children(0)
        sap_session = sap_connection.Children(0)


I tried a few things in Lazarus but it always sticks at the "Children(0)" connection with a ole type error 😔