ERPClimb logoERPClimb
Draft Handling
RAP / CDS / ODataadvanced 9 min read

Draft Handling Part 3: Draft Locking, ETags and Concurrency

Preview · a free account unlocks the full lesson

Key takeaway

Master concurrency in draft scenarios: the exclusive lock during editing, lock expiry and the optimistic phase, the total ETag at activation, and what users see in each situation.

In this lessonShow sections

Visual overview

Draft Handling Part 3: Draft Locking, ETags and Concurrency — learning sheetIn one line: Master concurrency in draft scenarios: the exclusive lock during editing, lock expiry and the optimistic phase, the total ETag at activation, and what users see in each situation.ERPClimb.com / RAP / LESSON 3/5 / LEARNING SHEETDraft Handling Part 3: Draft Locking, ETags andConcurrency1 · IN ONE LINEMaster concurrency in draft scenarios: the exclusive lock during editing, lock expiry andthe optimistic phase, the total ETag at activation, and what users see in each situation.2 · KEY IDEAS EXPLAINEDPhase 1 — Exclusive LockWhen user A clicks Edit, RAP locks the activeinstance (lock master on the root) and keeps itlocked while A works — across many requests. User…Phase 2 — Lock Expiry (Optimistic Phase)B may edit the object: B's Edit creates B's owndraft only if A's draft is discarded or has becomeinvalid — Fiori shows "Unsaved changes by…If B does not take over and A returns, A's Resumere-acquires the lock.The Total ETagunchanged → fine;changed (someone else saved the active objectmeanwhile, e.g. through an API) → Resume/Activateis rejected, preventing A from overwriting newer…ETag Master vs Total ETagetag master (LocalLastChangedAt, per entity) —protects individual non-draft changes (APIs,direct updates) and draft instance updates.total etag (LastChangedAt, root) — protects draftresume/activation against changes of the whole BO.3 · DO · AVOIDBest practice!Common mistakeAlways declare total etag on draft-enabledroots.Maintain both timestamp fields via @Semanticsannotations.Test concurrency with two users and an APIcall.✕Enabling draft without a total etag.✕Using the same field for etag master and totaletag without understanding both roles.✕Promising users fixed lock durations withoutchecking system settings.4 · IN A REAL PROJECTAn integration updated purchase request statuses every hour through an API. Occasionally, a buyer'slong-running draft was activated afterwards and silently reset the status set by the integration, because theBO had lock master but no total etag. After adding "total etag LastChangedAt" with the proper…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Edit sets an exclusive lock on the active instance, which is why other users see "Locked by …". That exclusive lock eventually expires — the draft itself stays, but another user may then start editing. A total ETag protects activation: if the active data changed while the draft existed, activation fails outright. Without that total ETag, a returning user could silently overwrite someone else's already-saved changes.

Part 2 walked through the draft lifecycle; this part answers the concurrency questions — who may edit while a draft exists, and what happens once a draft gets old.

In the first phase, the exclusive lock, when user A clicks Edit, RAP locks the active instance using the lock master on the root, and keeps it locked for as long as A keeps working, across many separate requests. User B sees "Locked by A" and simply cannot create a draft of their own. This is exactly what makes long editing sessions safe.

In the second phase, once the exclusive lock expires after a configured period, the draft itself still exists, but the situation changes.

User B may now edit the object, though B's Edit only creates B's own draft once A's draft is discarded or has become invalid — Fiori shows "Unsaved changes by A" and lets B decide whether to take over, which discards A's draft in the process.

If B doesn't take over and A comes back, A's Resume simply re-acquires the lock. It's worth checking with your basis or RAP team about the exact durations configured for the exclusive lock and the draft lifetime before promising users specific timings.

Free account

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

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.