Skip to Content
0

Running VB Scripts with SAP GUI from Citrix

Mar 22, 2017 at 06:49 AM

143

avatar image

Hi Everyone,

We are trying to execute a custom made VB Script to perform some actions in SAP after logging in the GUI.

The script works fine when we access SAP from locally installed SAP GUI software. But when we try using the same script on a session of SAP from Citrix server, it does not work.

Sample Script is as follows:

Start Notepad document. Paste content below. Save as “CoolScript.vbs”

Then once you have that log on to SAP and leave it with only one session open on the session manager home screen.

Double click the vbs file to execute. It should find your SAP GUI session and open the Project Builder transaction, then stop.

I would run scripts like this from our Access DB. For example, the user would navigate to the specific project and open the study characteristics page then activate the script.

The script would verify it was the right project, verify it was on the right screen, then copy the project legacy number from our system, enter it into the appropriate field in SAP and also open a new email to client services containing the number. This would tie everything together and ensure a perfect match for this very important reference number.

You should find that when running GUI locally it connects with no problem (or perhaps a security warning if set that way). When using streaming GUI through citrix the scripting engine cannot find the SAP instance to connect. There is no “SAPGUI” object in the registry.

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 = "cj20n"

session.findById("wnd[0]").sendVKey 0


Regards

Jigar Dedhia

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Rüdiger Specht Mar 23, 2017 at 12:20 PM
0

Did you start the script on the same Citrix-Server as SAP GUI? Otherwise both will not "see" each other.

Regards

Rüdiger

Share
10 |10000 characters needed characters left characters exceeded