Hi all,
I'm running a VBS script in SAP using variables (these last are dates, coming from a JS script, as an output), here below the 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
session.findById("wnd[0]/tbar[0]/okcd").text = ZRSVC001_D4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/txtV-LOW").text = "/LTP_H"
session.findById("wnd[1]/usr/txtENAME-LOW").text = ""
session.findById("wnd[1]/usr/txtENAME-LOW").setFocus
session.findById("wnd[1]/usr/txtENAME-LOW").caretPosition = 0
session.findById("wnd[1]").sendVKey 8
session.findById("wnd[0]/usr/ctxtJOBDATE").text = %CurrentDate%
session.findById("wnd[0]/usr/ctxtJOBDATE").setFocus
session.findById("wnd[0]/usr/ctxtJOBDATE").caretPosition = 10
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellColumn = "TOT"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").select
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:\Users\user\Documents\Downloads"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "Test.xlsx"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 9
session.findById("wnd[1]").sendVKey 11
When I'm running this script without using variables, but simply using string or integer, it works fine, otherwise I'm getting this error as soon as the script starts:
Microsoft VBScript compilation error: Expected Statement
If anyone could help
Appreciate
Thanks