You have a working managed RAP business object with a root and a child entity. The business now wants draft. What exactly do you change?
Say your answer out loud first.
Practise another way
In the base BDEF I add with draft, a draft table for every entity, and a total etag on the root next to lock master. I declare the draft actions Edit, Activate optimized, Discard, Resume and Prepare, and list every on-save validation, including the child's, in Prepare.
Compositions and to-parent associations get with draft. The projection BDEF gets use draft and the draft actions. In code I switch from %key to %tky so the draft indicator travels.
1. Base BDEF header: add with draft; after strict ( 2 );. Newer releases also offer with collaborative draft; so several users can work on one draft; check that your release has it before you promise it.
2. A draft table for every entity: draft table zbook_d. It mirrors the CDS entity's fields with their alias names, compatible types and a client field, and it must include the admin structure "%admin" : include sych_bdl_draft_admin_inc;.
With late numbering it also needs a DRAFTUUID key field. Never read or write it with ABAP SQL; only the framework does.
3. Total ETag on the root, after lock master, in its own field (not the etag master field), annotated @Semantics.systemDateTime.lastChangedAt: true.
When the exclusive lock of a draft expires, RAP compares the total ETag of draft and active instance to decide whether the draft can be resumed.
4. Draft actions:
managed implementation in class zbp_r_book unique;
strict ( 2 );
with draft;
define behavior for ZR_Book alias Book
persistent table zbook
draft table zbook_d
lock master
total etag LastChangedAt
etag master LocalLastChangedAt
authorization master ( instance )
{
create; update; delete;
association _Chapter { create; with draft; }
draft action Edit;
draft action Activate optimized;
draft action Discard;
draft action Resume;
draft determine action Prepare
{ validation validatePublishedDate; validation Chapter~validateTitle; }
}
Activate copies the draft into the persistent table and clears the draft; it runs Prepare implicitly. Prepare executes only the on-save validations and determinations you list, so list the child's too (Chapter~...).
5. Associations: the child gets draft table, and both directions say with draft (association _Book { with draft; }), so draft children always belong to draft parents.
6. Projection BDEF: use draft;, use action Edit; Activate; Discard; Resume; Prepare; and use association _Chapter { create; with draft; }.
7. Code and tests: every handler and EML call must carry %is_draft. Code that used %tky from day one survives; code with %key silently addresses only active instances. Review unit tests, jobs and other EML consumers for the same reason.
SAP's own flight reference scenario (/DMO/R_TRAVEL_D, branch ABAP-platform-2025) shows all of these pieces in one BO.
Lists the BDEF header, draft tables with the admin include, total etag, and draft actions with a complete Prepare list. Also names with draft on associations, projection use draft, and the %tky impact on code.
Says 'add with draft and a draft table' and stops, so validations never run in Prepare and child entities break.
A common mistake is to forget the child's on-save validations in `draft determine action Prepare`, or to keep `%key` in handlers. Then the UI shows errors only at activation, or the code reads the active instance while the user edits the draft.
- What is the difference between etag master and total etag?
- What does Activate optimized change?
- Why should you never SELECT from the draft table?
- How does a draft-enabled BO change your EML unit tests?
4 official pages and 1 prep guide. Confidence: high. Checked 2 Dec 2026.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.