SAP DB COMMIT DURING UPDATE



Get Example source ABAP code based on a different SAP table
  


VERSION 5 OUT

Forbidden Statements in Updates
In updates, that is, when an update function module triggered using COMMIT WORK is being processed, the following applies:
There can be no database commits or database rollbacks.
The update controller must not be modified.
If a database commit or database rollback occurs during an update, it terminates with a runtime error. Any statements that disrupt the update controller can produce undefined behavior.
Any statements that would produce a database commit or database rollback or would disrupt update control are therefore forbidden and produce a runtime error as soon as they are called and before the runtime error can occur in another place. These are the following statements:
The statements
COMMIT WORK
ROLLBACK WORK
COMMIT$|ROLLBACK CONNECTION on the standard database. produce a database commit or database rollback explicitly and hence produce the runtime errors COMMIT_IN_POSTING or ROLLBACK_IN_POSTING directly during the update.
The statements
CALL DIALOG
CALL SCREEN
CALL SELECTION-SCREEN
CALL TRANSACTION
LEAVE LIST-PROCESSING
LEAVE PROGRAM
LEAVE SCREEN
LEAVE TO LIST-PROCESSING
LEAVE TO TRANSACTION
SET SCREEN
SUBMIT produce either an implicit database commit or disrupt the update controller and hence produce the runtime error POSTING_ILLEGAL_STATEMENT directly during the update.
Executing the Native SQL statements COMMIT WORK and ROLLBACK WORK produces the runtime error POSTING_ILLEGAL_STATEMENT during the update.
Type A messages caught using the predefined exception error_message in function module calls execute the statement ROLLBACK WORK implicitly and produce the runtime message MESSAGE_ROLLBACK_IN_POSTING in updates.



Latest notes:

The runtime errors occur directly in those statements that would produce incorrect behavior during the update, which makes any errors easier to find than if, for example, the exception waited for an implicit database commit to occur.
Using the statement MESSAGE to send messages for the message types I, W, E, and A produces an implicit database rollback, but no direct runtime error can be raised here for reasons of downward compatibility. The behavior of messages in updates applies instead.
Synchronous or asynchronous remote function calls that generally produce a database commit, do not do so during update processing. During update processing, sRFC and aRFC can be used without producing a runtime error.
See also Authorization Checks in Updates.
ABAP_HINT_END
BEGIN_SECTION SAP_INTERNAL_HINT
Temporarily, the <(>NGAP<)> behavior was introduced for messages with 7.40, SP02 but had to be rolled back.
END_SECTION SAP_INTERNAL_HINT