When do you need COMMIT ENTITIES, and why can't you call it inside a behavior implementation? If your action changes a second business object with EML, how does that change get saved?
Say your answer out loud first.
Practise another way
COMMIT ENTITIES is what a consumer outside RAP writes, for example a class, a job or a unit test, to start the save sequence after MODIFY ENTITIES.
In a Fiori or OData call the runtime does it for me. Inside handlers and savers it is forbidden, because RAP owns the transaction.
If my action modifies another BO with EML, that change sits in the other BO's buffer. It is saved by the same commit as mine, in one LUW, or not at all.
What it does. COMMIT ENTITIES triggers the RAP save sequence for every business object touched in the current RAP transaction and ends with an implicit COMMIT WORK.
Without it, instances in the transactional buffer are never persisted. In natively supported scenarios, such as a Fiori app over OData, the runtime issues it for you.
Where you write it
MODIFY ENTITIES OF zr_request
ENTITY Request
UPDATE FIELDS ( Status ) WITH VALUE #( ( %tky = key Status = 'A' ) )
FAILED DATA(failed) REPORTED DATA(reported).
IF failed IS INITIAL.
COMMIT ENTITIES RESPONSES FAILED DATA(c_failed) REPORTED DATA(c_reported).
IF sy-subrc <> 0.
ROLLBACK ENTITIES. " clear buffers before going on
ENDIF.
ENDIF.
Use it in application jobs, console classes, event handler follow-ups outside RAP's own phases, and tests.
Always check sy-subrc: 4 means the early save phase (finalize, check_before_save) failed and you are back in the interaction phase; 8 means a failure in the late phase, which only savers based on CL_ABAP_BEHAVIOR_SAVER_FAILED can report, and then an explicit ROLLBACK ENTITIES is required before you continue.
Why not in a behavior implementation. SAP's cheat sheet states it directly: COMMIT ENTITIES cannot be used in behavior implementations.
RAP is the transaction owner in handler and saver methods, and its transactional contract also forbids COMMIT WORK and ROLLBACK WORK there. A commit in the middle would split one business transaction into several database LUWs.
Cross-BO changes from your action. Calling MODIFY ENTITIES OF zr_other_bo (without IN LOCAL MODE, since it is not your BO) inside your action is fine.
The other BO's provider puts the change in its own buffer. When the consumer, or the OData runtime, commits, the save sequence runs for all BOs in the transaction: all early phases first, then the late phases.
If the other BO's validation fails, the whole commit returns to the interaction phase, including your own changes. Map its failed and reported into yours so the user sees why.
Useful variants
COMMIT ENTITIES IN SIMULATION MODE: runs only the early save phase, nothing is written; good for a "check" button in a mass upload.COMMIT ENTITIES BEGIN ... ENDwithCONVERT KEY: read final keys of late-numbered instances.COMMIT WORKalso triggers the save sequence, but an early-phase error then ends in a runtime error instead ofsy-subrc4.
Says who issues the commit in OData versus EML consumers, why it is forbidden in handlers, how cross-BO EML joins one LUW, and interprets sy-subrc 4 and 8.
Adds COMMIT ENTITIES at the end of an action 'to make sure it saves', or believes each BO changed in an action gets its own commit.
Committing inside a handler to persist a cross-BO change. RAP saves all BOs of the transaction together; a commit in a handler is a contract violation and a runtime error in ABAP Cloud.
- What is the difference between COMMIT ENTITIES and COMMIT WORK when the save sequence finds an error?
- How would you use IN SIMULATION MODE for an upload preview?
- Your action creates a late-numbered instance in another BO. How do you get its final key?
1 official page and 2 prep guides. Confidence: high. Checked 3 Dec 2026.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Official page Backs the answer.