Sign in to follow this  
Followers 0
WladyslawMotyka

SAPGUI scripting works in AutoIt but not in luacom

6 posts in this topic

Hi folks,

I need help with connecting to SAPGUI using Lua. I saw that you folks have scripts for connecting and automation of SAP gui.

I try to use Lua and its LuaCOM but it did not work for me.

Have anybody ever try it?

My script bellow always fail on this call application:Children(0) and LuaCOM crash.

I don't know what am I doing wrong.

Could anybody help me with this? I would be grateful.

-- 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
-- session.findById("wnd[0]").restore
-- session.findById("wnd[0]").resizeWorkingPane 98,17,false
-- session.findById("wnd[0]/tbar[0]/okcd").text = "12"
-- session.findById("wnd[0]/tbar[0]/okcd").text = "3"

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")
c:\UserParameterSetter>lua.exe SAPconnect.lua
SapGuiAuto
_USERDATA_REF_  userdata: 01F03828

application
_USERDATA_REF_  userdata: 01F03878

connection

wm

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Why not use AutoIt as it works and LUA doesn't?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi,

our entire project is based on Lua so ... I am choosing an easier way :-)

Share this post


Link to post
Share on other sites

I'm not sure you will get a lot of help on this subject.

SAPGUI automation using Autoit is not very widely used. And I don't know how many users of this forum do it with LUA.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

:-(

Ok, but stil, i will wait a little and try my luck with this forum :-)

Share this post


Link to post
Share on other sites

Good luck :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0