COMMIT WORK statement in ABAP programming is used for closing the current LUW and save all the database change requests along with releasing all the database locks.
COMMIT WORK [AND WAIT]
WAIT addition is used for synchronous updating, that means the program will resume its execution till the update work finish, and it will continue after the database update. Otherwise it will be a asynchronous update (means the program wont wait for the database update).
When we call a COMMIT WORK the following actions are occurring in the system.
- Execute all subroutines registered using PERFORM ON COMMIT bases on the registration order.
- Trigger an internal event for the Persistence Service of the Object Services.
- It Handles the SAP locks associated with the current program.
- Trigger database commit and close the current database LUW and database cursors.
- Trigger the TRANSACTION_FINISHED event
The system field sy-subrc will contain the following follows when we execute this statement.
- sy-subrc= 0 If the WAIT addition is not specified.
- sy-subrc= 0 If the WAIT addition is specified and updating is successful.
- sy-subrc= 4 If the WAIT addition is specified and updating is failure.
Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes