SAP RAP ETag conflicts: Protect changes instead of bypassing the check
Two users edit the same manufacturer's operational record, and a later submission must not silently overwrite a newer saved value.
START HERE · NO PRIOR TOPIC KNOWLEDGE NEEDED
What it is. Why it matters.
An ETag represents a version of a service resource. RAP can use it to detect when another user changed data after a client read it, preventing accidental overwriting.
Completely new to SAP?
Manufacturers use SAP to connect work such as buying components, recording inventory, planning production, shipping equipment and accounting for costs. SAP S/4HANA is an enterprise resource planning system: it connects these activities through shared business data.
ABAP is SAP’s programming language for business applications. A program reads data, applies rules and produces a result. Start with the objects involved before investigating code.
A transaction code, or t-code, is a shortcut to a task in classic SAP GUI. Fiori apps provide another way to work. Names and screens depend on the product and release; you do not need a live system to learn the concepts in this guide.

Scope and source-review notes
Scope and evidence
Source review by FAST SAP SOLUTIONS® editorial. This badge describes our editorial review; it does not represent SAP certification or independent endorsement.
RAP OData optimistic concurrency for managed/unmanaged and draft scenarios; exact headers, responses and version maintenance depend on binding/provider release.
Primary documentation reviewed on 14 November 2026 using official indexed excerpts. Documentation review only; authored examples were not compiled or executed in an SAP system.
A MANUFACTURING EXAMPLE
Preserve another buyer's order update
Two editors, one record
Read the example values
- User A reads
- Version 1
- User B saves
- Version becomes 2
- User A submits
- Still references version 1
- Concurrency result
- Review version conflict
Words you’ll meet in this guide
- Program
- A set of instructions executed by a computer.
- Class
- A reusable unit that groups data with operations called methods.
- Database
- Organized information kept beyond one program execution.
- Internal table
- A list of rows held temporarily in an ABAP program’s memory.
- Key
- One or more fields used to identify or find a record.
- CDS
- Core Data Services: reusable definitions of business data and relationships.
- RAP
- ABAP RESTful Application Programming Model: a way to build business objects and services.
- OData
- A standard for reading and updating data through a web API.
- HTTP
- The request-and-response protocol used by web applications and APIs.
- ETag
- A resource-version identifier used in checks that can prevent overwriting a concurrent change.
- CSRF
- Cross-Site Request Forgery. A CSRF token helps a service reject unwanted cross-site write requests.
Preview the practical steps
SEE THE CONNECTION
See it in a simple example.
A small example to make the idea concrete.
Preserve another buyer's order update
Two users edit the same manufacturer's operational record, and a later submission must not silently overwrite a newer saved value.
An ETag conflict protects a version the client has not seen
A RAP OData ETag represents the version of a resource read by a client.
Scope and prerequisites
The guide covers RAP optimistic concurrency through OData for managed and unmanaged business objects.
How the version check prevents a lost update
A read supplies business fields and the associated ETag.
Preserve another buyer's order update
Two users edit the same manufacturer's operational record, and a later submission must not silently overwrite a newer saved value.
Compare the current resource version and the client's ETag before resolving the conflict or retrying with refreshed data.
| Reader | Business question | Evidence to carry forward |
|---|---|---|
| SAP developers and application teams supporting manufacturers | Preserve another buyer's order update | Compare the current resource version and the client's ETag before resolving the conflict or retrying with refreshed data. |
01 An ETag conflict protects a version the client has not seen
A RAP OData ETag represents the version of a resource read by a client. For a protected change, the service compares the supplied version with the current one. If another operation changed the resource, rejecting the stale request prevents an accidental overwrite. Treat that rejection as a concurrency outcome before treating it as a broken save button. [1] [2]
The repair is usually to reread, preserve the user's intended changes and reconcile them against current state. Removing the check or replacing the tag with a wildcard can discard that protection. This tutorial follows two editors of one order and distinguishes a real conflict from incorrect ETag maintenance.
02 Scope and prerequisites
The guide covers RAP optimistic concurrency through OData for managed and unmanaged business objects. Draft ETags and total ETags have related but different responsibilities. Record backend release, provider type, service binding and client model/version before changing behavior definitions or request handling.
You need a permitted two-session development fixture and sanitized read/change responses. The opaque tags v1/v2 below are teaching labels, not actual SAP-generated values. Copy real returned tags unchanged when testing. No service call or concurrent customer update was executed for this article, and protocol/UI error presentation must be checked in the actual binding.
03 How the version check prevents a lost update
A read supplies business fields and the associated ETag. A subsequent protected write sends that tag, commonly through If-Match in the OData request. Matching means the client is changing the version it observed; a successful modification must also advance the version so later stale clients can be detected. [1]
Optimistic concurrency does not mean the record is exclusively locked for the whole time a user thinks. Multiple clients can read it, and the version comparison protects the write boundary. A pessimistic lock and an ETag solve different coordination problems. Do not assume that adding one eliminates every need for the other in a draft or business-operation design. [1]
04 Worked case: amount 110 must survive another editor’s comment
Fictional order O100 begins at NetAmount 100 EUR and Comment “Review,” with versionv 1. Alex and Sam both readv 1. Alex changes the amount to 110 and saves successfully, producingv 2. Sam edits the comment to “Urgent” while still holding the old 100-EUR snapshot.
If Sam sends the entire stale object without protection, it can overwrite 110 with 100 while changing the comment. With a correct ETag check, the stalev 1 write is rejected. Sam should reread 110/v2, compare the intended comment change and submit an appropriate reviewed update against the current version. A partial PATCH reduces the payload but does not remove the need to respect cross-field business rules and version policy.
| Step | Server state | Client knowledge |
|---|---|---|
| Initial | 100 EUR / Review /v1 | Alexv 1; Samv 1 |
| Alex saves | 110 EUR / Review /v2 | Alex updated; Sam stillv 1 |
| Sam submits stale object | Must not silently restore 100 | Stale If-Match detected |
| Sam reconciles | 110 EUR plus reviewed comment | New read and current tag required |
05 Inspect the returned tag and outgoing request
Capture the read response for the exact entity and the later modifying request. Compare entity key, draft/active context and ETag source. Preserve quoting and weak-tag syntax exactly as returned; do not parse a timestamp-looking tag and reformat it. A tag copied from another entity or an earlier model cache is not the current resource version.
The illustrative exchange shows the shape of a stale write. A412 response is a standard precondition-failure pattern in the documented conditional handling; capture the actual status/body from your binding rather than promising one universal UI message. Authentication tokens, cookies and CSRF tokens are different security context and should not be confused with the resource ETag. [4]
GET /Orders('O100')
Response ETag: W/"v1"
Body: NetAmount 100, Comment Review
-- Another client changes the server to 110 and tagv 2. --
PATCH /Orders('O100')
If-Match: W/"v1"
Content-Type: application/json
{"Comment":"Urgent"}
Expected contract: stale precondition rejected; inspect actual response.06 Review provider and projection ETag responsibilities
The behavior definition identifies an ETag master field or dependency. The reviewed keyword documentation requires reliable updates of that field and readable access to it from dependent entities. In a managed provider, supported annotated administrative fields can be maintained by the framework. In an unmanaged provider, the application must implement the required handling. [2] [3]
Inspect the CDS administrative-field annotations, persistent mapping and read implementation as appropriate. Reusing optimistic concurrency in a projection uses the documented use etag contract. A declared ETag that never changes cannot protect concurrent edits, while a value changing on every read can cause false conflicts. Test the lifecycle rather than judging the field name. [2]
// Entity characteristics:
etag master LocalLastChangedAt
// Consumer must not edit the technical version field:
field ( readonly ) LocalLastChangedAt;
// Applicable projection behavior reuse:
use etag;07 Distinguish entity ETag from total ETag in draft handling
A draft-enabled BO also requires a total ETag for the documented active/draft transition checks. It refers to the complete business object and helps detect active changes when a draft is resumed after its exclusive lock expired. An entity's OData ETag and the total ETag therefore have different scopes. [2] [5]
The draft runtime can use draft-specific change information when checking modifications to a draft instance. Do not compare an active-instance tag with a draft request and assume they describe the same resource. Record IsActiveEntity or the corresponding technical draft identity with the business key. A conflict on resume needs the total-ETag/active-change investigation, not an arbitrary replacement of the item ETag. [1]
08 Reconcile user intent instead of automatically replaying stale data
Keep Sam's intended comment separately from the stale full object. Reread O100, show or evaluate the intervening amount change and apply only the intended permitted edit under the current business rules. If the comment's meaning depended on the amount being 100, a user decision may be required rather than an automatic merge.
A generic automatic retry that fetches a fresh ETag and resends the entire old snapshot can defeat conflict protection: it supplies a current token for stale values. The application must know what changed and whether reconciliation is valid. For uncertain network outcomes, verify whether the previous update already persisted before attempting another modifying operation.
A conflict review can use three values per editable field: original value read by Sam, Sam's intended edit and the latest server value. For NetAmount those are 100, unchanged by Sam and 110; for Comment they are Review, Urgent and Review. That comparison identifies the intended delta without treating Sam's untouched amount as a new request to restore 100.
If both editors changed Comment, the three-value comparison exposes a genuine same-field conflict that a blind merge cannot resolve safely. Preserve the competing text and let the application's supported reconciliation policy decide. After any successful reconciled update, record the newly returned tag and discard the stale baseline. Retrying with a current tag is valid only for a request rebuilt from the reviewed current state and intended delta, not for the previous full object. Exercise both independent-field and same-field cases in the controlled two-session fixture.
09 Troubleshooting real and false conflicts
Use the exact resource identity, tag progression and write path to distinguish legitimate competition from implementation defects.
| Observation | Question | Next evidence |
|---|---|---|
| Second editor rejected after first save | Expected stale version? | Two read tags and first write result |
| Single editor always rejected | Wrong/stale tag or different resource context? | Read/write key, draft flag and model cache |
| Both stale writes succeed | Version not advanced or check bypassed? | BDEF, provider update and request headers |
| Tag changes on every read | Incorrect maintenance? | Administrative field lifecycle |
| Child write not reflected in expected scope | Entity versus total/dependent ETag? | BO hierarchy and intended version scope |
| Draft resume rejected | Active changed after lock expiry? | Total ETag and active history |
| Retry overwrites newer amount | Old snapshot replayed with fresh tag? | Merge/delta algorithm |
10 Verify version progression and no-overwrite behavior
A positive single-client check reads O100, performs an allowed update with its current tag and verifies the new business value and new version. A negative check reuses the old tag and confirms rejection with no unintended change. The essential two-editor test verifies Alex's110 remains after Sam's stale request fails.
Boundary checks include a nonexistent key, a missing precondition under the service's documented policy, an update of a dependent entity and two tabs editing the same draft where supported. Verify the actual persisted values after every test, not only the HTTP status. These are proposed acceptance checks and require an authorized development environment.
11 Monitor competing writes and bypass paths
If conflicts become frequent, identify the other writers: batch jobs, integrations, actions or another UI. Confirm that they maintain the same version contract through supported business-object paths. A direct database update outside the model can change business data without the expected ETag progression, making the concurrency design incomplete.
Do not hide frequent conflicts with forced writes before understanding the business workflow. A smaller edit scope, clearer pending-change handling or a supported operation designed for one atomic business decision may improve the experience. Keep technical version fields read-only and avoid exposing them as ordinary editable user data.
12 Frequently asked questions
Is an ETag an authentication token? No. It describes resource version state; authentication and CSRF protection address different boundaries.
Can If-Match wildcard fix the error? It can remove the specific-version safeguard under applicable protocol behavior. That is not a general repair for stale user data.
Does PATCH make version checks unnecessary? No. A small payload can still depend on stale business state or conflict with another change.
Why does a draft resume conflict differ from ordinary save? Total ETag protects the complete active/draft transition under the documented lifecycle, while entity/draft tags protect their relevant resource versions.
What belongs in a support record? Entity key and draft context, read/write times, sanitized tag progression, other writer, provider responsibility and final no-overwrite verification.
Related services and next steps
Primary sources
Found this useful?
Share this guide with your network, or leave a like.
Your like is saved in this browser.