RAP Basics Part 11: Draft, Locking and Authorization
Preview · a free account unlocks the full lesson
Make a RAP BO safe for real multi-user use: draft handling (draft tables, Edit/Activate/Discard/Resume/Prepare, total ETag), pessimistic locking (lock master) and optimistic concurrency (ETags), and authorization at two levels — read access via CDS DCL and modify access via authorization master (global/instance).
In this lessonShow sectionsHide sections
Visual overview
Explanation
This final part is about making the business object ready for many users working at the same time. Draft lets users save incomplete work on the server: changes live in a draft table until Activate copies them into the active table.
In the BDEF header this is declared with with draft; entity: draft table ztravel_d, generated via quick fix, and the available draft actions are Edit, Activate optimized, Discard, Resume, and Prepare. Children need their own declaration too, for example association _Booking { create; with draft; }, and %is_draft inside %tky is what distinguishes a draft instance from an active one.
Locking in RAP is pessimistic by default: a lock master takes an exclusive lock on the active instance (for draft, this happens when editing starts), while a lock dependent lets children lock by _Travel, pointing back to the root. In a managed business object the framework sets the enqueue lock automatically; in an unmanaged one you implement the lock method yourself. With draft, the lock is held for the whole draft lifetime, from Edit until Activate or Discard.
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.