What does it do? 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 places in the update work process and in local updates in the current work process.
ABAP_PGL Do not implement in function modules and subroutines> ABAP_PGL_END
Latest notes:
Creating subroutines is obsolete. If new subroutines are required for PERFORM subr ON COMMIT> or PERFORM subr ON ROLLBACK>, they should only be used as wrappers for a method call and must not contain any other functional code.
Registered subroutines cannot have any parameter interface. Therefore, data can only be passed through external interfaces, for example, the ABAP memory. Subroutines that are executed in COMMIT WORK> or ROLLBACK WORK> are thus more suitable for management tasks, such as cleanup work at the end of a SAP LUW>, than for database changes.
During processing of a registered subroutine after COMMIT WORK> or ROLLBACK WORK>, the statements PERFORM ... ON COMMIT>, PERFORM ... ON ROLLBACK>, COMMIT WORK>, or ROLLBACK WORK > must not be executed. Type A> messages caught using the predefined exception error_message >> in function module calls execute the statement ROLLBACK WORK > implicitly and are therefore also forbidden.
Explicit database commits> or database rollbacks> are allowed during processing of a registered subroutine with COMMIT WORK> or ROLLBACK WORK >.
If, during the processing of a registered subroutine after COMMIT WORK>, update function modules are registered using CALL FUNCTION ... IN UPDATE TASK>> , this registration still applies to the current SAP LUW>.
If the registration of subroutines is combined with the registration of update function modules with CALL FUNCTION ... IN UPDATE TASK>>, special care has to be taken regarding the database LUWs> involved. Especially for asynchronous update >, procedures that are registered outside update processing are executed in different work processes and therefore in different database LUWs. The changes in the database LUW of the subroutine can be committed before the update function modules are executed and a database rollback during an asynchronous update does not rollback these changes. BEGIN_SECTION SAP_INTERNAL_HINT During the execution of a subroutine that was registered with ON COMMIT>, the internal system field sy-oncom> has the value P >. Instead of sy-oncom> the system class CL_SYSTEM_TRANSACTION_STATE > should be used in programs. END_SECTION SAP_INTERNAL_HINT ABAP_HINT_END • LEVEL PERFORM ON
ABAP Addition
What does it do? 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 ABAP Coding
Registering of a subroutine insert> of the same program for execution in the statement COMMIT WORK>>. The data is passed using the ABAP memory>. ABEXA 00497 ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA SAP LUW, ON COMMIT>> ABAP_EXAMPLE_END