on 2021 Nov 09 9:47 PM
My company uses a dashboard T-Code called Prometheus Navigator (T-Code: /PROGROUP/NAV), wherein I can assign specific T-Codes and Variants to run fully executed off an assigned command button. I am looking to take this one step further and automate the exporting of that data into Excel. Whenever a button is clicked, a new window/session is created. Running the SAP Script Record and Playback, the record always ends with
<session.findById("wnd[0]").resizeWorkingPane 88,16,false
session.findById("wnd[0]/usr/btnDASH_ALL-BO1-BU5-LABEL").press>
If I run a second script the long way, the code for exporting the data is recorded. However, when I combine the code, I get the "The control could not be found by id -" error message. Adding
<If Not IsObject(connection1) Then
Set connection1 = application.Children(0 + 1)
End If
If Not IsObject(session1) Then
Set session1 = connection1.Children(0 + 1)
End If>
before the export code, included with the original set codes, or any combination I can think of generates either the "The enumerator of the collection cannot find an element with the specified index -" or the "Object required: 'connection1' -"/ "Object required: session1' -" error message boxes.
It seems like my issue is how do I tell SAP to start running the script on the new session after the current session opens a new window?
Once I get that question answered, how can I identify specific sessions? My end goal is to have SAP trigger multiple sessions, export the data, the close that session.
Here is all of the script I am currently working with.
<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)
Set connection1 = application.Children(0 + 1)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
Set session1 = connection1.Children(0 + 1)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").resizeWorkingPane 88,16,false
session.findById("wnd[0]/usr/btnDASH_ALL-BO1-BU5-LABEL").press
If Not IsObject(session1) Then
Set session1 = connection1.Children(0 + 1)
End If
session1.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[1]").select
session1.findById("wnd[1]/usr/ctxtDY_PATH").text = "Z:\Rebar Fab Planning\DSI & Inventory Data Dumps"
session1.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "Inventory - MB52.XLSX"
session1.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
session1.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 48
session1.findById("wnd[1]/tbar[0]/btn[11]").press>
Request clarification before answering.
In order not to make it too complicated at the beginning, I would first consider only two consecutive sessions.
for example:
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]").resizeWorkingPane 88,16,false
session.findById("wnd[0]/usr/btnDASH_ALL-BO1-BU5-LABEL").press
wscript.sleep 4000 '4 seconds wait for a new session
Set session = connection.Children(0 + 1)
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[1]").select
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "Z:\Rebar Fab Planning\DSI & Inventory Data Dumps"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "Inventory - MB52.XLSX"
'unnecessary
'session.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
'session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 48
session.findById("wnd[1]/tbar[0]/btn[11]").press>
In a further step, it could be expanded to include any number of sessions.
Regards, ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for example:
...
set wshell = CreateObject("Wscript.Shell")
wshell.run "c:\tmp\sleep_4000.vbs",1,true
...
sleep_4000.vbs in c:\tmp 'This VB script only contains a single line.
wscript.sleep 4000
After that, it should work in both cases.Regards, ScriptMan
User | Count |
---|---|
4 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.