Showing results for 
Search instead for 
Did you mean: 

SAP GUI equivalent to VB.NET session.EndTransaction on C#



The idea is to go back to the main GUI window after the transaction execution.

In VB.Net the session.EndTransaction works fine.

What is the equivalent alternative when using C#?

GUI example as attached.

Please support.

Thank you.


View Entire Topic
Active Contributor

Hello @ptuga,

EndTransaction is a standard method from the session object. You can use it in C# as well as in The help describes it: "Calling this function has the same effect as SendCommand("/n")." The following sample code opens transaction SE16, waits 1 second and ends it with EndTransaction.

ID = InvokeMethod(session, "findById", new object[1]{"wnd[0]/tbar[0]/okcd"});
SetProperty(ID, "text", new object[1]{"/nSE16"});
ID = InvokeMethod(session, "findById", new object[1]{"wnd[0]"});
InvokeMethod(ID, "sendVKey", new object[1]{0});
InvokeMethod(session, "EndTransaction");

Best regards

0 Kudos

@stefan_schnell: Thanks for helping. I believe I have now understood a bit more how we can do some of these steps. Not easy without the recorder but still possible with VBA and Excel. Contrary to VS (VB.NET or C#) you can directly connect to SAP and see all methods and properties of the library using the reference SAP GUI Scripting API. While debugging, you can add watches and check the types and contents of the objects. Really helpful. When in VS (using SAPFEWSELib), expanding the objects on debugging does not give us any information. The Dynamic View comes up with an Error  -> Cannot evaluate expression since the function evaluation requires all threads to run. Is this how it should be? Am I missing something? 

By the way, without using your Tracker.exe, I would be blocked. Thank you for developing and share it to everyone.