ERPClimb logoERPClimb
RAP Basics
Architect / Cross-trackintermediate 8 min read

RAP Basics Part 5: Root Entity, Child Entity and Composition

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

RAP Basics Part 5: Root Entity, Child Entity and Composition — learning sheetFlow: Create table ZBOOKING_A with booking_uuid, parent_uuid, fields, admin fields → Add composition to ZI_Travel; create ZI_Booking with association to parent → Extend the BDEF with the child entity (lock/authorization dependent) → Add create by association on the root. Key ideas: COMPOSITION VS ASSOCIATION; THE CHILD VIEW; BDEF FOR THE TREE; BO BOUNDARY DESIGN. Watch out: Putting two independent objects in one composition tree makes them lock together — users block each other unnecessarily.ERPClimb.com / ARCH / LESSON 5/11 / LEARNING SHEETRAP Basics Part 5: Root Entity, Child Entity andComposition1 · HOW IT FLOWS1Create tableZBOOKING_A withbooking_uuid…2Add compositionto ZI_Travel;create…3Extend the BDEFwith the childentity…4Add create byassociation onthe root2 · KEY IDEAS EXPLAINEDComposition vs Associationcomposition [0..*] of ZI_Booking as _Booking —child belongs to the root.association [0..1] to ZI_Agency as _Agency — justa reference to another object.The Child Viewdefine view entity ZI_Booking … association toparent ZI_Travel as _Travel on$projection.TravelUUID = _Travel.TravelUUID.Child key usually its own UUID plus parent UUID asa normal field.Bdef For The TreeRoot: lock master, authorization master ( instance), etag master.Child: lock dependent by _Travel, authorizationdependent by _Travel, etag master (its own field).Bo Boundary DesignQuestion: must these objects be changed togetherin one transaction?Yes → composition. No → separate BOs linked byassociation.3 · REMEMBER · WATCH OUTRememberA RAP BO is a composition tree: one root entity and child (andgrandchild) entities that live and die with the root.Composition = existential dependency (bookings exist only within atravel); association = loose reference (travel → agency).The root is lock master and authorization master; children are lockdependent / authorization dependent via the to-parent association.!Watch outPutting two independent objects inone composition tree makes them locktogether — users block each otherunnecessarily.4 · IN A REAL PROJECTA distributor built a RAP BO where customer master extension data and all sales quotations for that customerwere one composition tree (customer as root, quotations as children). In go-live week, sales reps editingdifferent quotations for the same key account blocked each other, because the whole tree was locked through…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

Free account

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

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.