UiPath SAP VBS Script Custom Activity: How to?

Hello,

Currently working in a virtual environment running UiPath 2014.10.4. We are developing an SAP process and wanted to incorporate SAP Visual Basic Scripts so that we can get a few pieces of information that are not available through the UiPath UI Explorer.

I am looking for a method to run SAP visual basic scripts without having to keep the script files in a folder. From what I researched online the only mentioned way of doing this is through building a custom activity in Visual Studio. This script created through SAP using the Script Recording and Playback option.

I looked into the guide here: https://docs.uipath.com/activities/docs/creating-a-custom-activity on how to create and import these custom activities however I cannot get the code to work as expected. I included the code I tested below ( I have near 0 experience is Visual Studio). I expect this code to read the status message and return to me not only the message but the type and it’s ID so that we can determine exceptions at a broader level.

Do you have any examples of how to get this working or the necessary steps needed so that we can create a package out of this and run it in UiPath?

Thank you!

Imports System
Imports System.Drawing
Imports System.Data
Imports Microsoft.VisualBasic.Interaction

Dim SapGuiAuto As Object
Dim session As Object
Dim Application As Object
Dim Connection As Object

SapGuiAuto = GetObject(“SAPGUI”)
Application = SapGuiAuto.GetScriptingEngine
Connection = Application.Children(0)
session = Connection.Children(0)

msgText = session.findById(“wnd[0]/sbar”).Text
msgID = session.findById(“wnd[0]/sbar”).MessageID
msgType = session.findById(“wnd[0]/sbar”).MessageType

HI @JamesACA

I would recommend to start here: Tutorials on SAP, C# and more

where @StefanSchnell has a lot of real examples, how to work with SAP and how to create a packages.

Best regards, Lev

1 Like

@JamesACA

Hello James,

welcome in the UiPath Forum.

You can find a solution to handle your requirement in the SAP Community. I described a solution which you can use, but not in the context of UiPath, it is in the context of SAP Intelligent RPA. But it doesn’t matter, you can use this approach for yourself.

Best regards
Stefan

1 Like