What is draft in RAP, and how do the draft table, the draft actions and the total ETag work?
Say your answer out loud first.
Practise another way
Draft saves incomplete, possibly invalid user input to the database as it is typed, so work survives a crash or a lost session, even though OData is stateless. A draft-enabled BO has a draft table for each entity.
The framework provides the draft actions: Edit copies an active instance into a draft, Prepare validates, Activate turns the draft into the active instance, Discard deletes it, and Resume restores the lock. A total ETag detects an outdated draft.
Why draft exists. OData has no fixed back-end session, so the buffer cannot hold half-typed data. Draft persists the interim version in the database, and the user can leave, crash or switch device, then continue.
Enabling it
with draft;in the BDEF header, anddraft table zdraft_travelon each entity. It works for managed and unmanaged BOs.- The draft table has one field per CDS element plus the admin include
SYCH_BDL_DRAFT_ADMIN_INC. A quick fix in ADT generates it. With late numbering you also need aDRAFTUUIDkey. - You do not write to the draft table with SQL. The draft runtime does.
define behavior for ZR_Travel alias Travel
persistent table ztravel
draft table zdraft_travel
lock master total etag LastChanged
authorization master ( instance )
etag master LocalLastChanged
{
draft action Edit;
draft action Activate optimized;
draft action Discard;
draft action Resume;
draft determine action Prepare;
}
Draft actions (only on the lock master entity; in strict mode you must declare them explicitly)
- Edit: copies the active instance into a draft.
- Prepare: a determine action that runs determinations and validations declared for it, to check draft data before activation.
- Activate: runs Prepare, then creates or updates the active instance and deletes the draft. It changes the buffer. The database write is still the save sequence.
- Discard: deletes the draft. The active data is untouched.
- Resume: re-creates the lock when someone continues an expired draft.
Locks. Creating an edit-draft takes an exclusive lock on the active instance.
By default it lasts 15 minutes, then the draft turns optimistic and another user may change the active data or create their own draft. An untouched draft is removed after 28 days by default.
Total ETag. Mandatory for draft BOs, declared after lock master. It must change when the active instance changes and not while the draft lives. A lastChangedAt field fits.
The framework compares it between draft and active to allow or block Resume. The separate etag master field (local instance timestamp) changes on every draft write.
Gotcha: with draft, use %tky rather than %key, because it contains %is_draft.
Explains why draft exists, names the five actions with their effect, and knows the lock timing and total ETag purpose.
Says 'draft saves your data temporarily' and cannot name the draft actions or draft table.
Thinking Activate writes to the database. It writes to the buffer, and the save sequence persists it.
- Why is total ETag mandatory?
- What does Activate optimized change?
- What happens to a draft if someone changes the active record?
- Can draft be added to an existing production BO?
4 official pages, 2 prep guides and 1 technical reference. Confidence: high. Checked 21 Nov 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Technical reference Backs the answer.
- Prep guide Gives the question.
- Prep guide Gives the question.