Draft Handling
Draft handling is a mechanism in SAP Fiori apps, RAP and CAP that stores unsaved changes to a business object as a server-side draft, separate from the active data. Draft handling lets users resume interrupted work, run validations while editing and see when someone else is changing the same object, until Save turns the draft into the active version.
Quick facts
- Type
- Transactional pattern (interim version of a business object)
- Layer
- Business logic & data model, surfaced in UI applications
- Enabled in
- RAP behavior definition (with draft), CAP service model
- Variants
- Exclusive draft, collaborative draft
- UI support
- SAP Fiori elements for OData V2 and V4
- Who works with it
- ABAP and CAP developers, SAP Fiori developers
- Applies to
- SAP S/4HANA (all deployment options), SAP BTP
Layer: Business logic & data modelWhere it sits ▾
How does draft handling work?
In a draft-enabled app, editing follows four steps:
- A user chooses Edit on an existing object, or starts creating a new one. The back end creates a draft instance in a separate draft table.
- Every change is written to the draft in the background, so nothing is lost if the browser closes.
- Validations, field control and default values run against the draft while the user works, and messages appear before saving.
- Save activates the draft: its content becomes the active version and the draft is removed. Discard deletes the draft instead.
The active data stays untouched until activation: a purchase requisition for Cedar Office Supply at Alder Manufacturing can be started on Friday and finished on Monday. Draft handling therefore separates work in progress from business data at the persistence level, not only in the browser.
What is the difference between exclusive and collaborative drafts?
- Exclusive draft: one user owns the draft. Only the owner can change, activate or discard it, and other users cannot see the changes before they are saved.
- Collaborative draft: several authorized users can work on the same draft at the same time. In SAP Fiori elements for OData V4, the object page shows who is in the draft and locks a field while someone types in it.
In RAP, the choice is a single keyword in the behavior definition header: with draft for exclusive or with collaborative draft for collaborative drafts. Before planning collaborative draft, check the ABAP keyword documentation of your release for the keyword. Exclusive draft remains the common case, and collaborative draft fits objects that several people complete together.
How do locks and draft lifetime work?
Drafts change how locking behaves. In RAP:
- When a draft is created for an existing object, the active instance receives an exclusive lock that lasts for a set time, even if the user's session ends.
- After that period, the draft enters an optimistic lock phase. If the owner resumes, the framework tries to lock the object again.
- If someone changes the active object directly in the meantime, the draft becomes invalid.
- Drafts that stay untouched are discarded automatically by a draft life-cycle service, by default after 28 days according to SAP's RAP documentation.
A total ETag field, mandatory for draft-enabled RAP business objects, detects whether the active version changed while the draft existed. Draft handling thus replaces a short session lock with a longer reservation that eventually expires.
How do you enable draft handling?
- RAP: add the draft keyword to the behavior definition header, plus a draft table per entity and a total ETag. Draft applies to the whole business object, never to single entities. RAP supports draft from ABAP 7.55, which corresponds to SAP S/4HANA 2020.
- CAP: the annotation @odata.draft.enabled on the service entity enables draft, and the runtime handles it generically.
- Older SAP S/4HANA apps: drafts implemented with BOPF in the ABAP Programming Model for SAP Fiori still exist and can be carried into BOPF-based RAP business objects.
- SAP Fiori elements: the UI picks up draft from the service metadata. SAP states that full support for SAP Fiori elements on OData V4 services is granted only for draft-enabled scenarios. For OData V2, draft is not available on SAP NetWeaver AS for ABAP 7.50.
Draft handling is a service decision; the UI only reflects what the back end declares.
What are common mistakes with draft handling?
- Treating "locked by another user" as a bug. The message usually means a colleague has an open draft. Ask the owner to save or discard it, or wait for the lock phase to end.
- Reading the draft table directly. SAP warns that draft tables should only be accessed through the RAP framework, for example the Discard action.
- Forgetting the total ETag. A draft-enabled RAP business object requires one.
- Building an editable OData V4 app without draft. Users lose resume and lock information, and SAP Fiori elements offers only limited support.
Most draft handling problems come from misunderstanding the lock and lifetime rules, not from the framework.
Exclusive draft vs. collaborative draft vs. non-draft editing: what is the difference?
| Non-draft editing | Exclusive draft | Collaborative draft | |
|---|---|---|---|
| When data reaches the back end | Only on Save | Continuously, into the draft | Continuously, into the shared draft |
| Resume after interruption | No | Yes, by the owner | Yes, by all invited users |
| Concurrent editing | Prevented by a short session lock | Blocked while the exclusive lock holds | Allowed, with field-level locks |
| Typical use | Simple flows with few fields | Most transactional SAP Fiori apps | Objects completed by several people together |
FAQ
Where are SAP Fiori drafts stored?
Drafts are stored on the server in draft tables that belong to the business object, separate from the active tables. In RAP, every entity of a draft-enabled business object needs its own draft table, and the RAP framework writes and deletes the draft data.
How long does an SAP Fiori draft last?
In RAP, drafts that nobody touches are discarded automatically by the draft life-cycle service, by default after 28 days. The exclusive lock on the active object ends earlier, after which another user's direct change can invalidate the draft.
Why does an SAP Fiori app say the object is locked by another user?
Another user most likely has an open draft for the same object, and the exclusive lock phase of that draft has not ended. The owner can save or discard the draft; otherwise the lock expires and the draft moves to an optimistic phase.
Do all SAP Fiori apps use drafts?
No. Draft handling is a back-end decision per business object. Many current transactional SAP Fiori elements apps are draft-enabled, but non-draft apps exist, typically for simple editing flows where changes are sent only when the user saves.
Sources
- SAPUI5 SDK: Draft Handling (SAP Fiori elements for OData V4)
- SAP Help Portal: Draft Handling — exclusive and collaborative draft (RAP)
- SAP Help Portal: Pessimistic Concurrency Control (Locking) — locking in draft scenarios (RAP)
- SAP Help Portal: RAP BDL — Draft Handling (ABAP keyword documentation)
- SAP Help Portal: Service Binding — OData V4 and draft-enabled scenarios
- Applies to
- SAP S/4HANA on-premise · SAP S/4HANA Cloud Private Edition · SAP S/4HANA Cloud Public Edition · SAP BTP
- Last reviewed