EML Part 4: Cross-BO Calls, COMMIT ENTITIES and ROLLBACK ENTITIES
Preview · a free account unlocks the full lesson
Call other business objects safely with EML: changing a second BO from inside your BO, orchestrating several BOs from a program, where COMMIT ENTITIES and ROLLBACK ENTITIES belong, and what happens when one of them fails.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Several business objects changed through EML are saved together, or not at all. In programs, this means one COMMIT ENTITIES RESPONSES call per logical unit of work, with ROLLBACK ENTITIES used after a failed commit. COMMIT WORK is simply the wrong tool for RAP changes.
Parts 1 through 3 worked with a single business object, but real processes usually span several — approving a purchase request might create a budget reservation, or a migration program might create requests and attachments together. This part explains how several business objects end up sharing one transaction.
All business objects changed via EML in the same session share a single transactional context. When COMMIT ENTITIES is called, or the framework commits after an OData request, RAP runs the save sequence for every business object that has pending changes: finalize and check_before_save run for all of them first, and only if every one of them passes does save then run for all of them too. So either both the purchase request and the reservation get saved, or neither does.
Calling another business object from inside your own is allowed during the interaction phase — inside actions or determinations. You'd write something like MODIFY ENTITIES OF zr_otherbo … without IN LOCAL MODE, which means the other business object checks authorization and feature control for the current user, as covered in EML Part 3.
Its FAILED and REPORTED results should be mapped into your own failed and reported, so the user actually sees why something went wrong. What you must not do is call COMMIT ENTITIES yourself — the framework commits both business objects together at the end.
It's also not allowed to MODIFY any business object during the save phase itself — finalize, check_before_save or save — though reading is fine there; changes have to happen beforehand. And you should never change another business object's tables directly.
Where possible, prefer released interface business objects — the …TP variants — belonging to other teams or to SAP, rather than their internal base business objects, a distinction covered in Behavior Definitions Part 5.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.