ERPClimb logoERPClimb
Behavior Definitions
RAP / CDS / ODataintermediate 10 min read

Behavior Definitions Part 4: Associations, Compositions and Draft Declarations

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

Behavior Definitions Part 4: Associations, Compositions and Draft Declarations — learning sheetFlow: Check each child: association to parent in CDS and in BDEF body; no standalone create → Check each parent: association with create for its children → Run through the draft checklist item by item before activating → Test: create a request with items in Fiori, leave, resume, activate. Key ideas: ASSOCIATIONS IN THE BDEF; WHY CHILDREN HAVE NO STANDALONE CREATE; DEPENDENT LOCKING, AUTHORIZATION AND ETAG; DEEPER TREES. Watch out: References to other BOs stay in CDS, not in the BDEF.ERPClimb.com / RAP / LESSON 4/5 / LEARNING SHEETBehavior Definitions Part 4: Associations, Compositionsand Draft Declarations1 · HOW IT FLOWS1Check eachchildassociation to parent inCDS and in BDEF body; no…2Check eachparentassociation with createfor its children3Run through thedraft checklistitem by item…4Testcreate a request withitems in Fiori, leave…2 · KEY IDEAS EXPLAINEDAssociations In The BdefIn the parent: "association _Item { create;}" — enables create-by-association (items arecreated through the request) and…In the child: "association _Request;" —enables read-by-association to the parent, neededfor lock dependent and authorization dependent.Why Children Have No Standalone CreateA child without its parent is invalid. By omitting"create" in the child's body andoffering create only via the parent's association…Dependent Locking, Authorization And…lock dependent by _Request — the child is lockedby locking its root.authorization dependent by _Request — the childuses the root's authorization result.Deeper TreesFor root → item → schedule line: the schedule linedeclares "lock dependent by _Request"pointing to the root via its association (declare…3 · REMEMBER · WATCH OUTRememberChildren are created only via the parent association.The child declares association _Parent for dependentlock/authorization.Draft checklist: header, draft tables, total etag, actions, "withdraft" on associations, projection.!Watch outReferences to other BOs stay in CDS,not in the BDEF.4 · IN A REAL PROJECTAfter a developer enabled draft on a requisition BO, the Fiori app could create drafts, but adding an itemfailed with a generic error. The BDEF had "with draft" in the header and draft tables for bothentities, but the association declarations lacked "with draft", and the projection BDEF did not use…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

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.