on 2012 May 08 3:56 PM
I am using the SAP GUI Scripting API 7.10. My program is written in C#. I am using the following code (I have removed a lot of code for clarity sake).
SapROTWr.ISapROTWrapper SapROTWrapper = new SapROTWr.CSapROTWrapperClass();
object SapGuilRot = SapROTWrapper.GetROTEntry("SAPGUI");
object engine = SapGuilRot.GetType().InvokeMember("GetScriptingEngine",System.Reflection.BindingFlags.InvokeMethod, null, SapGuilRot, null);
GuiApplication GuiApp = engine as GuiApplication;
GuiConnection connection = GuiApp.Connections.ElementAt(0) as GuiConnection;
GuiSession session = connection.Children.ElementAt(0) as GuiSession;
As soon as the program executes the last statement above, the SAP session indicates via the 'barber pole' that a script is being executed. Basically, after the above statement my program will look at various text fields and complete it's need for its connection to the SAP scripting engine. The C# program will continue to run as long as the agent is logged into his/her workstation. The SAP program will continue to be used by the agent for data entry (they are in a call center). The 'barder pole' still continues to indicate that a script is being executed.
Is there a way in the SAP GUI Scripting API to stop the 'script' execution? Basically, my application is not a script and it does not look like the Scripting API was designed to handle this type of application. The only solution I have discovered so far is to have my program terminate, but this is unacceptable.
Thanks,
Dan
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
This is quite an old thread now ... did anyone ever find a resolution ?
My current code is amlost identical to Dan's first post and I am struggling to make sense of how to release the sessions without killing them for the user at the same time.
Any help appreciated!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Late to the party. You need to release the engine object.
Try something like this; in C#.
engine = SapGuilRot.GetType().InvokeMember("GetSCriptingEngine", System.Reflection.BindingFlags.InvokeMethod,null, SapGuilRot, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(engine);
GC.Collect();
GC.WaitForPendingFinalizers();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.