ABAP - Keyword Documentation →  ABAP - Programming Language →  Processing External Data →  ABAP Database Access →  Data Consistency →  SAP LUW → 
Mail Feedback

PERFORM, ON COMMIT, ROLLBACK

Short Reference

Syntax

PERFORM subr ON { {COMMIT [LEVEL idx]} | ROLLBACK }.

Addition:

... LEVEL idx

Effect

This statement registers the subroutine of the current program for later execution. The name of the subroutine is directly specified as subr. The subroutine is not executed immediately and is flagged for execution by one of the statements COMMIT WORK or ROLLBACK WORK instead.

The statements COMMIT WORK or ROLLBACK WORK execute the subroutines that are registered with ON COMMIT or ON ROLLBACK respectively in the current work process and before update function modules that are registered using CALL FUNCTION ... IN UPDATE TASK are called. Subroutines that are registered during execution of an update function module with ON COMMIT are executed at the end of the update. In non-local updates, this takes place in the update work process and in local updates in the current work process.

Programming Guideline

Do not implement in function modules and subroutines

Hints



Addition  

... LEVEL idx

Effect

In the case of subroutines registered for COMMIT, the order of execution can be controlled using the addition LEVEL, where idx expects a data object of the type i. The execution then takes place, sorted according to ascending value of idx. idx has the value 0, if a value is not explicitly specified. If the value is the same as idx or if no value is specified, the order of execution is the same as the order of registration. A subroutine registered multiple times for COMMIT or ROLLBACK is executed once in each case.

Example

Registering of a subroutine insert of the same program for execution in the statement COMMIT WORK. The data is passed using the ABAP memory.

FINAL(values) = VALUE demo_update_tab(
  ( id = 'X' col1 = 100 col2 = 200 col3 = 300 col4 = 400 )
  ( id = 'Y' col1 = 110 col2 = 210 col3 = 310 col4 = 410 )
  ( id = 'Z' col1 = 120 col2 = 220 col3 = 320 col4 = 420 ) ).

EXPORT values = values TO MEMORY ID 'INS'.
PERFORM insert ON COMMIT.

...

FORM insert.
  DATA values TYPE demo_update_tab.
  IMPORT values = values FROM MEMORY ID 'INS'.
  IF sy-subrc = 0.
    ...
  ENDIF.
ENDFORM.

Executable Examples