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

RAP Build-Along Part 3: Behavior Definition — Managed, Draft, Locking and ETags

Preview · a free account unlocks the full lesson

Key takeaway

Part 3 of the RAP Bootcamp turns the Travel + Booking data model into a transactional business object: a managed, draft-enabled behavior definition with persistent and draft table mapping, CRUD and create-by-association, lock and authorization master/dependent, local and total ETag, managed UUID numbering and field control.

In this lessonShow sections

Visual overview

RAP Build-Along Part 3: Behavior Definition — Managed, Draft, Locking and ETags — learning sheetIn one line: Part 3 of the RAP Bootcamp turns the Travel + Booking data model into a transactional business object: a managed, draft-enabled behavior definition with persistent and draft table mapping, CRUD and create-by-association, lock and authorization master/dependent, local and total ETag, managed UUID numbering and field control.ERPClimb.com / ARCH / LESSON 3/9 / LEARNING SHEETRAP Build-Along Part 3: Behavior Definition — Managed,Draft, Locking and ETags1 · IN ONE LINEPart 3 of the RAP Bootcamp turns the Travel + Booking data model into a transactionalbusiness object: a managed, draft-enabled behavior definition with persistent and drafttable mapping, CRUD and create-by-association, lock and authorization master/dependent…2 · KEY IDEAS EXPLAINED1The behavior definition (BDEF) `ZI_RAP_Travel`,the generated draft tables `ZRAP_TRAV_D` and`ZRAP_BOOK_D`, and an (initially empty) behaviorpool `ZBP_I_RAP_TRAVEL`. After this part the BOcan be created, changed, and deleted through EML,with drafts, locks and optimistic concurrency…2CDS describes *data*. The BDEF describes *what mayhappen to it*: which operations exist, who ownslocks, how concurrency is detected, where data issaved, and which custom rules run. In a managedscenario, the framework implements the standardoperations (create, update, delete, read, lock…3Right-click `ZI_RAP_Travel` → *New BehaviorDefinition*, implementation type Managed. ADTgenerates a skeleton for the root and everycomposed child. Replace it with the full BDEF inthe code section. Walk through it block by block.4┏━━ CODE ━━━━━━━━━━━━ ┃ managed implementation inclass zbp_i_rap_travel unique; ┃ strict ( 2 ); ┃with draft; ┗━━━━━━━━━━━━━━━━━━━3 · DO · AVOIDBest practice!Common mistakeEnable the strictest strict mode your releasesupports.Root owns lock, authorization and total ETag;children are dependent.Use managed UUID numbering; fill readable IDsin a determination or late numbering.✕Forgetting the `mapping for` block when CDSaliases differ from DB fields — saves write…✕Hand-writing the draft table instead ofgenerating it; any alias drift breaks…✕Declaring `create` on the child instead ofcreating only by association.4 · IN A REAL PROJECTA support team received tickets that two dispatchers could edit the same travel's bookings simultaneously in acustom app, with the last save silently winning. The BO had declared the child as its own lock master and hadno local ETag. Changing the child to `lock dependent by _Travel`, adding `etag master LocalLastChangedAt` with…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

This part builds the behavior definition (BDEF) ZI_RAP_Travel, the generated draft tables ZRAP_TRAV_D and ZRAP_BOOK_D, and an initially empty behavior pool ZBP_I_RAP_TRAVEL. After this part the business object can be created, changed, and deleted through EML, with drafts, locks, and optimistic concurrency all handled by the managed framework — custom logic such as determinations, validations, and actions is only declared here, with Part 4 implementing it.

Before starting, Part 2 should be complete, with active tables ZRAP_TRAVEL and ZRAP_BOOKING and a root ZI_RAP_Travel with a composition to ZI_RAP_Booking, and your release should support strict mode and draft for managed BOs — strict ( 2 ) is available in the current SAP BTP ABAP Environment and recent S/4HANA releases, though older releases may only support strict or no strict mode at all, depending on release.

CDS describes data; the BDEF describes what may happen to it — which operations exist, who owns locks, how concurrency is detected, where data is saved, and which custom rules run. In a managed scenario, the framework implements the standard operations (create, update, delete, read, lock, draft handling, save) straight from this declaration, so you write ABAP only for behavior that's genuinely business-specific.

To create the BDEF, right-click ZI_RAP_Travel and choose New Behavior Definition with implementation type Managed; ADT generates a skeleton for the root and every composed child, which then gets replaced with the full definition, walked through block by block below.

The header reads managed implementation in class zbp_i_rap_travel unique; strict ( 2 ); with draft; — managed means the framework handles standard operations and save; implementation in class ... unique means one behavior pool serves the whole BO, with each entity getting its own local handler class inside it; strict ( 2 ) enforces current best-practice rules, such as explicit authorization and no deprecated syntax, surfacing issues that would otherwise only appear at runtime; and with draft draft-enables the whole BO, so all composed children become draft-enabled along with it.

Persistence and draft table mapping is declared with persistent table zrap_travel and draft table zrap_trav_d.

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.