Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  Data Consistency →  SAP LUW 


Quick Reference

Other versions: 7.31 | 7.40 | 7.54




The statement COMMIT WORK closes the current SAP LUW and opens a new one. All change requests from the current SAP LUW are then committed. In this case, COMMIT WORK performs the following actions:

  • It executes all subroutines registered using PERFORM ON COMMIT.

    The order is based on the order of registration or according to the priority specified using the addition LEVEL. The following statements are not allowed to be executed in a subroutine of this type:


    The statement CALL FUNCTION ... IN UPDATE TASK can be executed.

  • It raises an internal event for the persistence service of the Object Services.

    If event handlers are registered by the persistence service, they collect the changes to the objects managed by the service and use CALL FUNCTION ... IN UPDATE TASK to pass them to a special update function module, registered as the final update module.

  • It triggers the processing of all update function modules registered using CALL FUNCTION ... IN UPDATE TASK in the update work process or, for local updates, in the current work process as well.

    All high-priority ("VB1") update function modules are executed in the order of their registration and in a shared database LUW. If the addition AND WAIT is not specified, the program does not wait (in non-local updates) until the update work process has executed it (asynchronous updates), but instead is resumed immediately after COMMIT WORK. However, if the addition AND WAIT is specified, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

    When all high-priority update function modules are completed successfully, the statement executes the low-priority ("VB2") update function modules in the order of registration in a shared database LUW in the update work process.

    No database commits and no database rollbacks can occur and the update control cannot be modified in the processing of an update function module triggered using COMMIT WORK is being processed. Any statements that would produce this situation are forbidden statements in updates and always produce runtime errors. As before, no authorization checks can be made.

    After the execution of high-priority update function modules, the function modules registered using CALL FUNCTION ... IN BACKGROUND UNIT and CALL FUNCTION ... IN BACKGROUND TASK (which is obsolete) are themselves executed in a single database LUW per RFC destination.

  • It handles all SAP locks set in the current program in accordance with the value of the formal parameter _SCOPE of the corresponding lock function modules.

  • It triggers a database commit on all currently open database connections, which also terminates the current database LUW and closes all database cursors.

  • The COMMIT WORK still raises the event TRANSACTION_FINISHED from the system class CL_SYSTEM_TRANSACTION_STATE, where the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK. The time when this event is raised is described in the documentation for the event in the class:

    Resources for preparation work can be cleaned up in the event handlers for this event before the update is performed. However, this is no guarantee that the update has not already been performed.

    If the statement COMMIT WORK is executed by calling special programs, be aware of the following:

    System Fields

    sy-subrc Meaning
    0 The addition AND WAIT was specified and the update of the update function modules was successful.
    4 The addition AND WAIT was specified and the update of the update function modules was not successful.

    The statement COMMIT WORK always sets sy-subrc to 0 if the addition AND WAIT is not specified.


    • An SAP LUW not closed by COMMIT WORK but by ending the current program or closing the internal session is ignored by the registered procedures. Registered update function modules remain on the database but can no longer be executed.
    • The statement COMMIT WORK closes all database cursors. ABAP SQL statements that access a database cursor later (SELECT loop and FETCH) raise a non-handleable exception.
    • If a runtime error occurs in an update triggered by a COMMIT, the update work process executes a database rollback, logs this in the corresponding database tables, and notifies the user whose entries created the entries by SAPMail. After the cause of the error has been resolved, the canceled entries can be updated again.
    • The statement PERFORM ... ON COMMIT can be executed in updates. The registered subprogram must be defined in the current function group and is then executed at the end of the current update.
    • COMMIT WORK also triggers a database commit in programs called using CALL DIALOG.
    • COMMIT WORK empties global temporary tables of all currently open database connections and prevents the runtime error COMMIT_GTT_ERROR in the case of implicit database commits.


    Registers various update function modules using CALL FUNCTION IN UPDATE TASK and triggers a synchronous update using COMMIT WORK AND WAIT.

    DATA(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 ) ). 
        values = values. 

    Executable Examples


    Non-Handleable Exceptions

    • Cause: COMMIT WORK is not allowed within a FORM called using PERFORM ... ON COMMIT.
      Runtime error: COMMIT_IN_PERFORM_ON_COMMIT
    • Cause: COMMIT WORK is not allowed within the update.
      Runtime error: COMMIT_IN_POSTING