Unable to get Output using Invoke VBScript Code

Hi All,

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 !!

@Indranil_Dey

Create an out argument of type string in invoke code and assign the text variable to that value…then it can be passed out

Cheers

Hi Anil,

Can you please elaborate how to do that as I am only able to add input arguments in Invoke VBscript as mentioned in screenshot.

image

Same issue in above post as well. I need exactly same way. But no resolution as of now.

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

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.