Skip to Content
0
Former Member
May 05, 2009 at 09:43 PM

Object Oriented Transaction Mode

77 Views

Hello,

is it possible when using the object oriented transaction mode (for example in a separate method), to avoid the commit work in the calling report? Even there is a rollback work, the commit is done.

Example:

REPORT  ztest.

data: l_test type ztest.
data: lo_ootrans type ref to ztest2.

select max(id)
from ztest
where l_test-id.
l_test-id = l_test-id + 1.

insert ztest from l_test.

create object lo_ootrans.
call method lo_ootrans->create.
rollback work.

The code of method create is following:


method CONSTRUCTOR.

CL_OS_SYSTEM=>INIT_AND_SET_MODES(
                                  I_EXTERNAL_COMMIT = OSCON_FALSE
                                i_update_mode = OSCON_DMODE_UPDATE_TASK ).

endmethod.

method CREATE.

data: TM type ref to IF_OS_TRANSACTION_MANAGER,
        T  type ref to IF_OS_TRANSACTION.
data l_test type SPFLI.
data: AGENT      type ref to CA_SPFLI_PERSISTENT,
        CONNECTION type ref to CL_SPFLI_PERSISTENT.
data: EXC type ref to CX_ROOT,
        TEXT type STRING.

  TM = CL_OS_SYSTEM=>GET_TRANSACTION_MANAGER( ).
  T  = TM->CREATE_TRANSACTION( ).

  l_test-CARRID     = 'XY'.
  l_test-CONNID     = '123'.

  AGENT = CA_TEST_PERSISTENT=>AGENT.

  try.

      T->START( ).

      CONNECTION = AGENT->GET_PERSISTENT( I_CARRID = l_test-CARRID
                                         I_CONNID = l_test-CONNID ).
      l_test-DEPTIME = CONNECTION->GET_DEPTIME( ).
      l_test-ARRTIME = CONNECTION->GET_ARRTIME( ).
      l_test-DEPTIME = WA_SPFLI-DEPTIME - 3600.
      l_test-ARRTIME = WA_SPFLI-ARRTIME - 3600.
      CONNECTION->SET_DEPTIME( l_test-DEPTIME ).
      CONNECTION->SET_ARRTIME( l_test-ARRTIME ).

      T->END( ).

    catch CX_ROOT into EXC.

      TEXT = EXC->GET_TEXT( ).
      message TEXT type 'I'.

  endtry.

endmethod.

After the rollback work in the report the insert to table ztest is done. Can this commit to table ztest be avoided?

Thx for your help,

Best regards