CDS Associations Part 4: Associations vs Compositions in a RAP Business Object
Preview · a free account unlocks the full lesson
Understand the CDS side of a RAP business object tree: composition vs association, "association to parent", and how projections redirect compositions, parents and normal associations.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 1 through 3 used associations purely for reading. RAP business objects add a second kind of relationship on top of that: the composition. This lesson covers the CDS syntax for it, while RAP Business Objects Part 1 covers the design decision behind it.
An association describes two entities that are related but each have their own lifecycle — a sales order refers to a customer, but deleting the order does not delete the customer. A composition describes a child that is actually part of the parent: a purchase request item exists only within its request, deleting the request deletes the items along with it, and locks, authorization and saves all go through the root.
On the root side, the root view entity ("define root view entity") declares composition [0..*] of ZR_PurchReqItem as _Item. There's no ON condition here, since it's derived from the child's own "association to parent," and the cardinality is usually [0..*] or [1..*].
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.