OData V4 Part 6: ETags and Optimistic Concurrency
Preview · a free account unlocks the full lesson
Understand optimistic concurrency in OData V4 with RAP: how ETags are delivered, how clients send If-Match, what 412 and 428 mean, and how RAP etag master fields drive the whole mechanism.
In this lessonShow sectionsHide sections
Visual overview
Explanation
The server sends an ETag with every read, exposed as @odata.etag in the JSON or as an ETag header for single entities. The client is expected to send it back in If-Match on PATCH, DELETE and action calls. A mismatch produces 412 Precondition Failed, while a missing If-Match where one is required produces 428. If-Match: * disables the check entirely and should never be used in a business client.
Parts 1 through 5 covered calls and errors; this final part explains one mechanism that every write client must implement: ETags, with RAP Business Objects Part 4 covering the matching BO-side behavior.
The underlying problem is this: two users read the same request at 9:00. User A changes the amount at 9:05. User B changes the description at 9:10, still working from the 9:00 data. Without protection, B's write would silently win, and B would never even see that A had made a change. Locks can't help here, because the two changes weren't simultaneous — this is a lost-update problem, not a concurrency-timing problem.
ETags solve this by versioning each entity. In RAP, "etag master LocalLastChangedAt" defines which field acts as the version field, and its value changes on every update. When a client reads an entity, OData returns that version as "@odata.etag" in the JSON, and as an ETag header for single entities — for example, W/"20260924090000.1234560".
When the client later sends a PATCH, DELETE or action, it includes that value as If-Match: W/"20260924090000.1234560". RAP then compares it against the current value: if they're equal, the change is allowed; if they differ, the server returns 412 Precondition Failed, and the client must re-read the data and let the user decide how to proceed.
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
Interview questions on this topic
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.