public abstract class JCoContext extends Object
begin()
and
end()
methods. This is typically used for multi-step logical units of work (LUWs), in which several function
modules are executed in a row and are committed afterwards.JCoDestination destination = JCoDestinationManager.getDestination("<DestinationName>"); try { JCoContext.begin(destination); function1.execute(destination); function2.execute(destination); functionBapiTransactionCommit.execute(destination); } catch (AbapException ex) { ... } catch (JCoException ex) { ... } catch (Exception ex) { ... } finally { JCoContext.end(destination); }Internally, the JCo runtime considers all calls executed in the current session and scope between
begin()
and
end()
as coherent and sends the calls over the same connection. Stateful contexts can be nested. The respective
connection will be released only after the root context is ended, i.e. end()
needs to be called as many times
as begin()
was called before for a specific destination.Modifier | Constructor and Description |
---|---|
protected |
JCoContext()
Only used internally.
|
Modifier and Type | Method and Description |
---|---|
static void |
begin(JCoDestination destination)
Begins a stateful call sequence for calls to the specified destination.
|
static void |
end(JCoDestination destination)
Ends a stateful call sequence for calls to the specified destination.
|
static boolean |
isStateful(JCoDestination destination)
Returns
true if in the current session a stateful call sequence has been started and is not finished yet. |
public static void begin(JCoDestination destination)
begin(JCoDestination)
and end(JCoDestination)
will not be reset or closed. As a consequence
the user context in the ABAP back-end will be kept.JCoContext.begin()
reserves a connection for exclusive usage, you should only switch to
the stateful context if this is really required. Stateless processing should be preferred whenever possible,
i.e. avoid using JCoContext.begin(
/JCoContext.end()
sequences if the used function modules do not
store any state in the ABAP system.destination
- The destination for which to start a back-end context for processing stateful call sequences.public static void end(JCoDestination destination) throws JCoException
end()
has been called as many times as method
begin()
was called before for a specific destination.destination
- The destination whose back-end context shall be ended.JCoException
- in case releasing/closing any connection runs into an issue.public static boolean isStateful(JCoDestination destination)
true
if in the current session a stateful call sequence has been started and is not finished yet.
That means method begin()
was invoked but not end()
, or more precisely: begin()
has been
invoked more often than end()
for the specified destination.false
if there is no stateful call sequence active in the current session.The
- destination for which the stateful context shall be checked.Copyright © 2019 SAP. All Rights Reserved.