Mentor SAP

ETag Handling in SAP Gateway

In the Service Builder, you create ETags at the entity type level. Here you can mark one property as the ETag property. The ETag header field in a response provides information about the status of a resource. If the client performs a read or wants to perform an update at a later point in time, the client can use the ETag to check whether the data has changed in the meantime.

 

Using ETags will result in less data being read and more security for the client when performing updates.

 

 

ETags Conditional Read Requests

If ETags are used for conditional read requests, the client can check whether the resource has changed without the need to read all of the data.

 

If the ETag sent by the client does not match, this indicates that the resource has changed. The client then receives the changed data in the HTTP response. If the ETag matches, this indicates that the data has not changed and the client can work with the data that is locally available.

 

 

Conditional Update Requests

If ETags are used for conditional update requests, the client can check whether the resource has changed. The data will not be updated if the ETag sent by the client do not match.

 

Use the HTTP request: http header: if-match.

 

If both ETags match, the HTTP Response is empty, and the status code is 204. If both ETags do not match, the HTTP response contains an error message; the status code is 428: precondition required.

 

 

How Does ETag Handling Support Work?

When using the generic framework support with ETags, the following happens:

 

Before an update is performed, the gateway framework on the hub performs a READ request and compares the ETag sent by the client with the ETag retrieved from the back end.

 

Instead of using the generic framework support, you can perform a code-based implementation in the SAP Business Suite back-end system. This has some advantages since it requires, for example, fewer round trips between the client and the SAP Gateway server.

 

The Gateway server framework offers the following generic support for the handling of ETags:

 

The Gateway back-end framework offers the following support for the handling of ETags: