cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting API doesn't work with SAPGUI 720 patch 3

Former Member
0 Kudos

Hi,

It seems that scripting API doesn't work with SAP GUI for Windows 720 patch 3 on Windows 7 platform.

Following VB example works with 710 (all patches) and 720 without patch, or with patch 1 & patch 2 but not with patch 3.

Scripting is allowed both on server and client sides.

Any similar experience ?

Thanks

J-Philippe

Module Module1

Sub Main()

Dim SapApplication = CreateObject("Sapgui.ScriptingCtrl.1")

Dim NewConnection = SapApplication.openConnectionByConnectionString("xxx.xxx.xxx.xxx 00")

' SAP GUI 720 # 3 -> Return false

If NewConnection.DisabledByServer Then

Console.WriteLine("!!! Scripting Disabled !!!")

Console.ReadLine()

End If

' SAP GUI 720 # 3 -> COMException: The enumerator of the collection cannot find en element with the specified index.

Dim SapSession = NewConnection.Children(0)

SapSession.FindById("wnd[0]/usr/txtRSYST-BNAME").text = ("user")

SapSession.FindById("wnd[0]/usr/pwdRSYST-BCODE").text = ("pass")

SapSession.FindById("wnd[0]").sendVKey(0)

Console.WriteLine("Hit a key ...")

Console.ReadLine()

SapSession.FindById("wnd[0]").close()

SapSession.FindById("wnd[1]/usr/btnSPOP-OPTION1").press()

End Sub

End Module

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Found in #4 readme file <<gui720_4-10007878 : 2010/11/09 Scriping: doesn't work if used by CreateObject, note 1526624 >>

Scripting seems work with #4

Thanks.

Former Member
0 Kudos

Dear J-Philippe,

I'm just getting started with SAP GUI Scripting through the COM interface and I seem to be running into the same issue.

You seem to be referring to a work-around mentioned in the README (#4). I don't know where the README is located, could you (or somebody else) please post the work-around or the README or location thereof?

By the way, here's the code I'm running (it's Python):

import win32com.client

wrapper = win32com.client.Dispatch("SapROTWr.SapROTWrapper")
sap_gui = wrapper.GetROTEntry("SAPGUI")
application = sap_gui.GetScriptingEngine

connection = application.FindById("con[0]") # returns /app/con[0]
session = connection.FindById("ses[0]") # throws exception

The last statement fails with an exception "The control could not be found by id".

When I use connection.Children(0) instead I get the exception "The enumerator of the collection cannot find an element with the specified index"

Same results when using SapGui.ScriptingCtrl.1.

Thanks!

Edited by: brucevdk on Jan 31, 2011 7:51 PM

I found the mentioned SAP note 1526624 somewhere (I don't yet have access to the official resource) and it made me think that perhaps I'm not dealing with the same issue. I'm also not sure what CreateObject is and if it's similar to the Dispatch functionality above (I'm just getting started with COM Programming). I'll play around with the recorder at work tomorrow to see if scripting works at all.

Former Member
0 Kudos

Hi,

In this thread I pointed out that scripting doesnu2019t work with SAPGUI 720 patch 3,

but seems to work with SAPGUI 720 patch 4.

The read me file named u201Cgui720_4-10007878u201D is a text file delivered with SAPGUI 720 patch 4.

The issue I mention is specific to patch level; I wanted SAP to confirm that.

Regards,

Jean-Philippe