Show TOC

UserTransactionLocate this document in the navigation structure

Definition

As with LocalTransaction , UserTransaction should be allocated first. All transactional activities running under this user will then be included in UserTransaction as soon as it is started and as long as it is not completed by COMMIT or ROLLBACK .

Example
  1. Create UserTransaction :

    UserTransaction userTransaction = (UserTransaction) initialcontext.lookup("java:comp/UserTransaction");

    or get UserTransaction from Servlets Context (valid only for Servlets).

    UserTransaction userTransaction = m_sessionContext.getUserTransaction();

  2. Start userTransaction :

    userTransaction.begin();

  3. Create Interaction and Records , then fill records with business data.

    execute first call MappedRecord output1 = (MappedRecord)interaction.execute(null, input1);

  4. Evaluate output1 and use it to fill the new input2 with some data.

  5. Execute a second call:

    MappedRecord output2 = (MappedRecord)interaction.execute(null, input2);

  6. Execute more calls, if needed.

  7. If all these calls were processed successfully, then commit LocalTransaction :

    userTransaction.commit();

    After COMMIT , all statements written with UPDATE TASK in ABAP will be persisted in the data base.

  8. Otherwise execute a ROLLBACK :

    userTransaction.rollback();

    In this case all statements written with UPDATE TASK will be discarded.