Show TOC

Procedure documentationExecuting Stateful Calls Locate this document in the navigation structure

 

You need a stateful connection to an SAP server if you want to execute multiple function calls in the same session (in the same context).

Therefore, you need to declare a stateful connection explicitly.

Procedure

As of JCo 3.0 a stateful connection requires the statements JCoContext.begin(destination) and JCoContext.end(destination).

Example

Syntax Syntax

JCo Client: Stateful connection

  1. JCoDestination destination = ...
  2. JCoFunction bapiFunction1 = ...
  3. JCoFunction bapiFunction2 = ...
  4. JCoFunction bapiTransactionCommit = ...
  5. JCoFunction bapiTransactionRollback = ...
  6.  
  7. try
  8. {
  9. 	JCoContext.begin(destination);
  10. 	try
  11. 	{
  12. 		bapiFunction1.execute(destination);
  13. 		bapiFunction2.execute(destination);
  14. 		bapiTransactionCommit.execute(destination);
  15. 	}
  16. 	catch(AbapException ex)
  17. 	{
  18. 		bapiTransactionRollback.execute(destination);
  19. 	}
  20. }
  21. catch(JCoException ex)
  22. {
  23. 	[...]
  24. }
  25. finally
  26. {
  27. 	JCoContext.end(destination);
  28. }
  29.  
End of the code.