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.
As of JCo 3.0 a stateful connection requires the statements JCoContext.begin(destination) and JCoContext.end(destination).
Syntax
JCo Client: Stateful connection
JCoDestination destination = ...
JCoFunction bapiFunction1 = ...
JCoFunction bapiFunction2 = ...
JCoFunction bapiTransactionCommit = ...
JCoFunction bapiTransactionRollback = ...
try
{
JCoContext.begin(destination);
try
{
bapiFunction1.execute(destination);
bapiFunction2.execute(destination);
bapiTransactionCommit.execute(destination);
}
catch(AbapException ex)
{
bapiTransactionRollback.execute(destination);
}
}
catch(JCoException ex)
{
[...]
}
finally
{
JCoContext.end(destination);
}