SAP Knowledge Base Article - Public

2789959 - Howto query delta change through OData API

Symptom

You have a requirement to query delta changes for CorporateAccountTaxNumber through Odata API. However the Etag is not filterable and there is no property 'Last Changed on'

Environment

SAP Cloud for Customer

Reproducing the Issue

Check URL https://<Tenant URL>/sap/c4c/odata/v1/c4codataapi/$metadata

Then you can find:

<Property Name="ETag" Type="Edm.DateTimeOffset" Nullable="true" Precision="7" ConcurrencyMode="Fixed" sap:creatable="false" sap:updatable="false" sap:filterable="false"/>

Cause

ETag is only meant for calculating ETag header for concurrency control. Hence, ETag has been made fitlerable=false from 1811 onwards for all new services including c4codataapi and new custom OData services. In case, you need to filter on LastChangedOn property on any entity set (Collection), you could check for a similar attribute e.g. ChangedOn, LastChangedOn, LastUpdatedOn on the header entity type and do a $expand as below to get the required data.

Please note that, usually,  "ChangedOn" is not specific to an entity type but is same across BO i.e. value would be the same for all entity types which are based on the BO. Hence, you could simply filter on the header and expand to the required collection via navigation.

Resolution

Please filter on the header and expand to the required collection via navigation.

https://<Tenant URL>/sap/c4c/odata/v1/customer/CorporateAccountCollection?$filter=ChangedOn ge datetimeoffset'YYYY-MM-DDT00:00:00.0000000Z'&$expand=CorporateAccountTaxNumber

Please note that, If a specific service doesn't have "ChangedOn" even on the header entity type and  if the requirement is urgent, please create custom services on relevant BOs and add LastChangedDateTime as a property. This way relevant ObjectIDs of the headers can be retrieved using $filter on the LastChangedDateTime property and these ObjectIDs can be used as filters in standard API e.g. c4codataapi.

If a custom service creation has any issues (or) if not urgent, you could raise a requirement to SAP to add "ChangedOn" property on the header entity type of the service.

Keywords

ODATA; ETag; Delta Changes , KBA , AP-RC-ODF , OData framework (C4C Only) , How To

Product

SAP Cloud for Customer core applications 1905