Skip to Content

SAP GUI Scripting - C# can't get session

Apr 02 at 11:36 AM


avatar image
Former Member

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

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
avatar image
Former Member Apr 03 at 07:21 AM

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.

10 |10000 characters needed characters left characters exceeded