Three travels are saved in one request, and check_before_save finds an error in only one of them. What happens to all three, which saver methods run next, what is left in the buffer, and what does your EML caller see?
Say your answer out loud first.
Practise another way
I explain that the whole transaction stops, not just the bad travel. RAP calls cleanup_finalize, where I undo what finalize changed, and returns to the interaction phase.
Nothing reaches the database, and the buffer keeps all three travels so the user can fix one and save again. My EML caller gets sy-subrc 4 after COMMIT ENTITIES, with the failed travel in the late FAILED response and its messages in REPORTED.
The rule. The early save phase checks all BOs in the RAP transaction. If finalize or check_before_save reports a failure for any instance, RAP rejects the late save phase for the whole transaction. There is no partial save of the two good travels.
Methods called after the failure
cleanup_finalize. It exists to roll back the changes made infinalize. In your own saver logic, undo anything you prepared there, such as derived values or a planned number.- The transaction returns to the interaction phase.
adjust_numbers,saveandcleanupdo not run.
What remains. The transactional buffer still holds all three travels with their changes. The user, or the EML caller, can correct the instance and call COMMIT ENTITIES again. ROLLBACK ENTITIES discards everything instead; it calls cleanup.
What the EML caller sees
COMMIT ENTITIES RESPONSE OF zr_travel
FAILED DATA(commit_failed)
REPORTED DATA(commit_reported).
IF sy-subrc = 4.
" one or more instances failed in the early save phase
" commit_failed-travel names them, commit_reported explains why
ROLLBACK ENTITIES. " or correct and commit again
ENDIF.
The response types are the late variants (TYPE RESPONSE FOR FAILED LATE, REPORTED LATE).
What a Fiori user sees. The OData request fails, and the messages arrive. In a draft app the error was usually found already during Prepare, so it shows on the field.
For state messages, SAP describes a special case. If the rollback happens in an OData request, state messages raised during that request are converted to transition messages, because the persisted state did not change.
If a non-RAP EML consumer is stopped in check_before_save, the BO keeps its state and the state messages are preserved.
How to design for it
- Keep
finalizereversible. Do not draw numbers or call external systems there that cannot be undone incleanup_finalize. - Report errors per instance with the right
%tky, so the caller can tell the good travels from the bad one. - A batch job that must save the good rows needs its own design. For example, commit in smaller packages and handle failed packages separately.
Says the whole transaction is rejected, names cleanup_finalize and the return to the interaction phase, keeps the buffer, and shows COMMIT ENTITIES with sy-subrc 4 and the late response.
Expects the two good travels to be saved, or says cleanup runs and the buffer is cleared after a failed check.
Expecting a partial save. A failure in the early save phase stops every BO in the transaction, so a job must split its work if good rows should be kept.
- What would you put in cleanup_finalize in an unmanaged BO?
- How would a nightly load save the good records when a few fail?
- What changes if the error only appears in the save method itself?
3 official pages 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.
- Official page Backs the answer.
- Official page Backs the answer.