If you need to process several calls to an SAP system and make sure that either all calls have been completed or none have been completed, you can make use of JCA’s transactional support.
You can control transactions by yourself, using JCA LocalTransaction or JTA (Java Transaction API) UserTransaction.
For details on the API see: http://java.sun.com/j2ee/1.4/docs/api/index.html.
These two transaction types are application managed transactions.
Alternatively, you can let a container control transaction handling by using container managed transactions.
Using EJBs, you will need to make relevant entries in ejb-jar.xml to notify the EJB container, whether you are using Container or Application (= Bean) managed transactions.
For the Application managed transaction:
<transaction-type> Bean </transaction-type>
And for the Container managed transaction:
<transaction-type> Container </transaction-type>
Note that when using the SAP JRA transaction management, no remote functions should be called, that execute database-statements directly (call COMMIT WORK) instead of using the update-process. As of SAP release 4.0, BAPIs don’t execute database statements directly and allow the application to do this or not.
There are a number of exceptions. For details, see SAP note 131838.
You should not call any BAPIs mentioned in this note. However, you can write your own BAPIs in ABAP. When designing your own BAPIs all writing of database statements should be done in the update task (i.e. following statement in your BAPI coding: CALL FUNCTION 'MY_UPDATING_FUNCTION' IN UPDATE TASK). Only in this case is it possible to complete JCA transaction with commit or rollback.
This transaction handling only makes sense for synchronous calls, that is for calls using the method
public Record execute(InteractionSpec interactionSpec, Record input) (see Client Programming Model).
Calls using tRFC require specific transaction handling and would not be affected by JCA or JTA transaction handling.
For more information on the different transaction types, see: