RAP Basics Part 5: Root Entity, Child Entity and Composition
Preview · a free account unlocks the full lesson
Model multi-level RAP business objects: root and child entities, composition versus association, the to-parent association, lock master and lock dependent, authorization master and dependent, create-by-association, and how the composition tree defines the BO boundary.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 4 fixed the implementation type; now we extend the business object from a single entity into a tree. A RAP BO is a composition tree: one root entity with child, and sometimes grandchild, entities that live and die along with the root.
Composition means existential dependency — bookings exist only within a travel — while association is a loose reference, such as a travel pointing to an agency.
The root acts as lock master and authorization master, while children are lock dependent and authorization dependent through their to-parent association, and children are always created through the parent, via create by association, for example _Booking { create; }.
Composition is declared as composition [0..*] of ZI_Booking as _Booking, meaning the child belongs to the root, whereas an association such as association [0..1] to ZI_Agency as _Agency is just a reference to a separate object. Deleting the root deletes all composition children too — this cascades automatically in a managed BO.
A child view adds an association back to its parent, for example define view entity ZI_Booking ... association to parent ZI_Travel as _Travel on $projection.TravelUUID = _Travel.TravelUUID, with the child's key typically its own UUID plus the parent's UUID as a normal field.
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.