Skip to Content
0

SAP GUI Scripting - C# can't get session

Apr 02 at 11:36 AM

29

avatar image
A S

I am trying to use standard sample to get active session:

SapROTWr.CSapROTWrapper sapROT = new SapROTWr.CSapROTWrapper();
object objSapGui = sapROT.GetROTEntry("SAPGUI");
object objEngine = objSapGui.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, objSapGui, null);
SapGuiApp = objEngine as GuiApplication;
var sapconnections = SapGuiApp?.Connections
               .Cast<GuiConnection>().ToList();

I can get connection, but see that sapconnections.FirstOrDefault().Sessions.Count or sapconnections.FirstOrDefault().Children.Count equals to 0.

Even if I am loggined in and can see window:

PS: probably session information is getting lost after Cast<GuiConnection>()

capture.png (98.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
A S Apr 03 at 07:21 AM
0

Seems that scripting was disabled on server side. Now session is getting catched. Strange. I was sure that I have enabled scripting on server side. May be also permission to record scripts was also required(?) - i have set this time this permission to true also.

Share
10 |10000 characters needed characters left characters exceeded