I just started learning SAP GUI Scripting and cannot figure out why my macro is not recorded properly.
I tried to record all the steps for a transaction at once. But every time I do it, a script contains only the part up until the line where a transaction is run. The rest of the steps are not recorded.
I decided to record two parts separately and combine them manually. But it still does not work.
The macro only runs "/oCS15" transaction, it then stops and returns the error message:
the control could not be found by id. Line 20, Char 1
Can anyone advise how to fix a problem? I really hope to move on with this part of the project and assume it is just a minor issue. Please help!
I have the following script:
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]/tbar[0]/okcd").text = "/oCS15"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkRC29L-DIRKT").selected = true
session.findById("wnd[0]/usr/ctxtRC29L-MATNR").text = "EDG001001008"
session.findById("wnd[0]/usr/chkRC29L-DIRKT").setFocus
session.findById("wnd[0]").sendVKey 5
session.findById("wnd[0]/usr/ctxtRC29L-WERKS").text = "0600"
session.findById("wnd[0]/usr/ctxtRC29L-WERKS").setFocus
session.findById("wnd[0]/usr/ctxtRC29L-WERKS").caretPosition = 4
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellColumn = "DOBJT"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").doubleClickCurrentCell
session.findById("wnd[0]/usr/tabsTS_ITEM/tabpPHPT/ssubSUBPAGE:SAPLCSDI:0830/btnP_BEZIEHUNG").press
session.findById("wnd[0]/usr/cntlSOURCE/shellcont/shell").setSelectionIndexes 0,28