Eine Stateful-Verbindung zu einem SAP-Server benötigen Sie immer dann, wenn Sie mehrere Funktionsaufrufe innerhalb der gleichen Session (im gleichen Kontext) durchführen wollen.
Dazu ist es notwendig, eine Stateful-Verbindung explizit als solche zu deklarieren.
Verwenden Sie für eine Stateful-Verbindung die Anweisungen JCoContext.begin(destination)und JCoContext.end(destination).
JCo Client: Stateful-Verbindung
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); }
|