Behavior Definitions Part 4: Associations, Compositions and Draft Declarations
Preview · a free account unlocks the full lesson
Declare the relationships of a business object correctly in the BDEF: composition associations with create-by-association, read-by-association, dependent locking and authorization, and every declaration needed to enable draft.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 2 and 3 covered one entity at a time. This part covers how the entities of a BO tree are connected inside the BDEF, and the exact set of declarations required for draft. (CDS Associations Part 4 explains composition versus association on the CDS side.)
Only associations that belong to the BO tree are declared in the BDEF body. In the parent, "association _Item { create; }" enables both create-by-association — items are created through the request — and read-by-association, via READ ENTITIES … BY \_Item.
In the child, "association _Request;" enables read-by-association back to the parent, which is needed for lock dependent and authorization dependent. Without "create" in the braces, the association stays read-only, meaning the child can't be created at all except through another path.
Options can narrow this further: "association _Item { create ( features : instance ); }" allows adding items only in certain states, and "internal create" restricts adding children to the BO itself. Associations to other BOs, such as supplier or product, stay in CDS only and are never declared in the BDEF.
Children having no standalone create is deliberate: a child without its parent is invalid, so by omitting "create" in the child's own body and offering create only via the parent's association, the BDEF makes it impossible to create an orphan without writing any code for it. EML reflects this by using CREATE BY \_Item with %cid_ref or the parent key.
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.