I am trying to run one SAP Script using Invoke code script, I am able to get value using msgbox inside VBScript code but getting output using WScript.Echo Variable.
Please find below code,
Dim text
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[1]/btn[20]”).press
session.findById(“wnd[1]/usr/ctxtLFA1-KTOKK”).caretPosition = 4
text= session.findById(“wnd[1]/usr/ctxtLFA1-KTOKK”).text
MsgBox text
WScript.Echo text
Last comand is not working to get output in UiPath. Can someone help !!
Issue resolved , it was script issue. Please find below SAP script.
Dim strText
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[1]/btn[20]”).press
session.findById(“wnd[1]/usr/ctxtLFA1-KTOKK”).caretPosition = 4
strText= session.findById(“wnd[1]/usr/ctxtLFA1-KTOKK”).text
session.findById(“wnd[1]/tbar[0]/btn[0]”).press
'MsgBox text
WScript.Echo strText