RAP Build-Along Part 3: Behavior Definition — Managed, Draft, Locking and ETags
Preview · a free account unlocks the full lesson
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 sectionsHide sections
Visual overview
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.
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
More lessons in this topic
- RAP Basics Part 1: RAP Architecture — Layers, Artifacts and When RAP Fits
- RAP Basics Part 10: EML — Entity Manipulation Language
- RAP Basics Part 11: Draft, Locking and Authorization
- RAP Basics Part 2: Data Model Design — Tables, Keys, Administrative Fields and Interface Views
- RAP Basics Part 3: Projection Layer and Metadata Extensions
- RAP Basics Part 4: Implementation Types — Managed, Unmanaged, Additional Save and Unmanaged Save
- RAP Basics Part 5: Root Entity, Child Entity and Composition
- RAP Basics Part 6: Behavior Definition — CRUD, Field Control and Features
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.