Keep incomplete work separate until it is ready
A buyer may need to enter a request in stages and return later. Draft-enabled RAP gives the user a draft lifecycle; the RAP runtime orchestrates draft handling rather than asking the application to write the draft table directly.
Enable draft handling
with draft;
define behavior for ZR_PURCHASE_REQUEST alias Request
persistent table zpurchase_request
draft table zpurchase_request_d
lock master
{
create;
update;
draft action Edit;
draft action Activate;
draft action Discard;
}
This is an instructional fragment, not a complete draft BO. Draft tables require the correct technical fields and relationship to the active model; ADT-generated artifacts are a safer starting point than hand-building the table from this excerpt. Activate moves validated draft data into the active lifecycle; Discard abandons the draft.
Draft adds persistence, locking, authorization, and service considerations. Use it when users need an edit-and-resume workflow, not as a default for every BO.
Sources
Developer practice · ABAP
Practice: trace a draft edit and activation
Enable draft in a RAP behavior header and name the draft persistence table in the entity definition.
Complete the task using the syntax and structure described above. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.
0 required structures detected · 0 checks
Write your solution, then check its structure.
One possible solution
with draft;
define behavior for ZR_PURCHASE_REQUEST alias Request
persistent table zpurchase_request
draft table zpurchase_request_d
lock master
{
create;
update;
draft action Edit;
draft action Activate;
draft action Discard;
}