Add VBscript

Hi All,

I would like to insert SAP script in Uipath.
I have already add invoke VBscript activity, add the file name. Then nothing is happening.
Please someone guide me, how to add argument and run my script.

You don’t use UiPath to run scripts in other applications.

Tell us what you’re trying to do.

You csn pass thr arguments easily to a vb script.

Regarding script for SAP, I assume you established a connection first with SAP?

Hi @Asitabha_Deb_asitabhad

I have tried to run the sap script from excel application and when you copy paste the sap script it wont run out of the box.

you need to perform below steps to run the script from any external application such as excel or UiPath

  1. Add reference SAP GUI Scripting API
  2. Attach the existing SAP session
  3. Run the SAP Script

Reference SAP GUI Scripting API

SAP Gui reference

Attach to SAP session

GuiApplication Object - SAP Help Portal

To connect and login SAP application automatically using VBScript - Visual Basic 4 / 5 / 6 (bytes.com)

Finally you can copy paste SAP Recording script in the invoke code and run

I don’t suggest to use SAP scripting in Invoke code, because UiPath SAP activities are more than enough to accomplish many tasks

Let us know what you want accomplish with scripting, we can help you doing it using other activities

@Asitabha_Deb_asitabhad

Hello Asitabha,

you can find examples how to pass arguments to a VBScript, in the context of SAP, in SAP GUI Scripting Development Scenarios and in How to check SAP Network Speed. You can find an example how to detect connection and session number, for a seamless SAP GUI Scripting integration. And also you have the possiblity to use a lot of standard window attributes.

image

Best regards
Stefan

Hi @johnfelix,

Thanks for this feedback. Can you please help me what is the path of above check point.
I have added all the parameter for run SAP script.
Here is my 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]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/subSUBSCREEN_BUTTONS:SAPMV45A:4050/btnBT_PEIN”).press
session.findById(“wnd[0]/tbar[1]/btn[29]”).press
session.findById(“wnd[0]/tbar[1]/btn[7]”).press
session.findById(“wnd[1]/usr/btnBUTTON_1”).press
session.findById(“wnd[1]/usr/btnBUTTON_2”).press
session.findById(“wnd[0]/tbar[0]/btn[3]”).press

Please do let me know if I need to add any variable in the script. May be I missed that part.

BR/Deb

Hi @postwick ,

I am trying to run SAP script through UiPath.
I have recorded the script and trying to run in invoke VBScript activity but its not running and its showing “Green Tick” in Debug mode.

Here is my 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]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/subSUBSCREEN_BUTTONS:SAPMV45A:4050/btnBT_PEIN”).press
session.findById(“wnd[0]/tbar[1]/btn[29]”).press
session.findById(“wnd[0]/tbar[1]/btn[7]”).press
session.findById(“wnd[1]/usr/btnBUTTON_1”).press
session.findById(“wnd[1]/usr/btnBUTTON_2”).press
session.findById(“wnd[0]/tbar[0]/btn[3]”).press

Please do let me know if I miss anything.

Hi @Asitabha_Deb_asitabhad

I am super curios, why you would want to write a VB script and have all debugging stuff you discussing right now.

Why not to use UiPath Studio and UiPath activities to perform all your action with NO-CODE approach?

Thanks, Lev

1 Like

Hi @LevKushnir ,

I thing, activity with VBScript is much faster then normal sequence based approach.
For certain repetitive task VBScript is more reliable then normal approach.

What do you think.

BR/Deb

HI @Asitabha_Deb_asitabhad

Check this thread, where @StefanSchnell discussing the performance topic Performance Consideration of an SAP GUI for Windows Automation

Best regards, Lev

1 Like