I have already created a gui scripting to automate some task. Now, there is a part where I needed to get the SAP system ID / Name. I need get the system ID / Name where the user is currently logged on.
Currently I am using Q4N. So far below is my Code:
Dim app As Variant
Dim SAPGUIAuto As Object
Dim Connection As Variant
Dim session As Variant
Dim MainPage as Worksheet
set MainPage = Sheets("Main")
If Not IsObject(app) Then
Set SAPGUIAuto = GetObject("SAPGUI")
Set app = SAPGUIAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = app.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 app, "on"
End If
Set Info = session.Info()
MainPage.Range("E22") = Val(Info.SystemName())
I tried to display this Info.SystemName() but it gives me zero number.
I also tried recording a script in order to get this info:
Unfortunately, there is no recorded step for me to be able to get the system ID.