Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAP connection #11

Open
trax100 opened this issue Jul 14, 2014 · 0 comments
Open

SAP connection #11

trax100 opened this issue Jul 14, 2014 · 0 comments

Comments

@trax100
Copy link

trax100 commented Jul 14, 2014

Hi,
does anybody tryied connect to SAP Gui and its ScriptingEngine???
In VBScript you have to run this code

    If Not IsObject(application) Then
       Set SapGuiAuto  = GetObject("SAPGUI")
       Set application = SapGuiAuto.GetScriptingEngine
    End If
    If Not IsObject(connection) Then
       Set connection = application.Children(0)
    End If
    If Not IsObject(session) Then
       Set session    = connection.Children(0)
    End If
    If IsObject(WScript) Then
       WScript.ConnectObject session,     "on"
       WScript.ConnectObject application, "on"
    End If

    session.findById("wnd[0]").maximize

But in LuaCOM it failed at connection = application:Children(0)
see the Lua code

function help(t)
    for k,v in pairs(t) do print(k,v) end
end

require("luacom")

-- luacom.config.abort_on_API_error = true
-- luacom.config.abort_on_error = false

print("SapGuiAuto")
-- local Wrp = luacom.CreateObject ("SapROTWr.SapROTWrapper")
-- local SapGuiAuto = Wrp:GetROTEntry ("SAPGUI")
local SapGuiAuto  = luacom.GetObject("SAPGUI")
if not SapGuiAuto then error("SapGuiAuto missing") else help(SapGuiAuto) end
print()

print("application")
local application = SapGuiAuto:GetScriptingEngine()
if not application then error("application failed") else help(application) end
print()

print("connection")
local connection = application:Children(0)
if not connection then error("connection failed") else help(connection) end
print()

print("session")
local session = connection:Children(0)
if not session then error("session failed") else help(session)end
print()

   -- WScript.ConnectObject session,     "on"
   -- WScript.ConnectObject application, "on"

-- session.findById("wnd[0]").maximize

print("working") 

Program output:


c:\l>bin\lua.exe SAPconnect.lua
SapGuiAuto
USERDATA_REF userdata: 0071A000

application
USERDATA_REF userdata: 01E52AC0

connection

c:\l>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant