[ABAP] Transaktionsdienst (Objektorientiert)

* https://help.sap.com/saphelp_nw70/helpdata/de/fa/f23c18330411d5992100508b6b8b11/content.htm?no_cache=true
* https://rvanmil.wordpress.com/2011/04/14/using-the-transaction-service/
* https://archive.sap.com/discussions/thread/3338833
* https://help.sap.com/saphelp_erp60_sp/helpdata/de/f5/a3682ebc6911d4b2e80050dadfb92b/frameset.htm

* Typgruppe: OSCON
* Update modes
*   OSCON_DMODE_DIRECT           local updates (like the procedural SET UPDATE TASK LOCAL)
*   OSCON_DMODE_UPDATE_TASK      asynchronous updates
*   OSCON_DMODE_LOCAL            local updates (like the procedural SET UPDATE TASK LOCAL)
*   OSCON_DMODE_UPDATE_TASK_SYNC synchronous updates (like the procedural COMMIT WORK AND WAIT)
*   OSCON_DMODE_DEFAULT          (OSCON_DMODE_UPDATE_TASK)
* Programme:
*   DEMO_TRANSACTION_SERVICE
*   DEMO_CREATE_PERSISTENT

CLASS lcl_ta_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS on_finished FOR EVENT finished OF if_os_transaction
      IMPORTING
          status.
ENDCLASS.

CLASS lcl_ta_handler IMPLEMENTATION.
  METHOD on_finished.
    IF status = oscon_tstatus_fin_success.
      WRITE: / 'Update erfolgreich.'.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.

  TRY.
      cl_os_system=>init_and_set_modes( i_external_commit = oscon_true
                                        i_update_mode     = oscon_dmode_default ).

      DATA(o_tam) = cl_os_system=>get_transaction_manager( ).
      DATA(o_ta) = o_tam->create_transaction( ).

      SET HANDLER lcl_ta_handler=>on_finished FOR o_ta.

      o_ta->start( ).
      
      ...

* ruft implizit COMMIT WORK
      o_ta->end( ).
    CATCH cx_root INTO DATA(e_txt).
      WRITE: / e_txt->get_text( ).
  ENDTRY.