Client Dependency in CDS Views
The CDS view can be made client dependent/client independent which basically depends on the CDS view data source. The new annotation @ClientHandling.type should be used instead of the old annotation @ClientDependent.
The annotation @ClientHandling.type value can be:
#INHERITED – If one of the data source is client dependent then the CDS view is client dependent. If all the data sources are client independent then the CDS view is client independent.
#CLIENT_DEPENDENT- If at least one data source is client dependent, then CDS view is client dependent else results in error.
#CLIENT_INDEPENDENT – All the data sources must be client independent , then CDS view is client independent else results in error.
Below is the CDS view with client handling annotation set as – @ClientHandling.type: ##INHERITED . The data source SPFLI is client dependent, so the CDS view is client dependent.
The MANDT field added to the SQL view.
The data source – SPFLI DB table is client dependent.
Preview the CDS view and it brings 27 records from the current client in which it executed. The CDS result list didn’t include the CLIENT field. Go to the SQL console.
This SQL query on CDS entity is executed and brings 27 records .
In the query it self- ” CLIENT SPECIFIED” can be added which brings records from all the clients but in the result set CLIENT field is not added.
If CLIENT field to be added in the result set then the below part must be added after CLIENT SPECIFIED .
Now lets consume this CDS view in ABAP report SQL Query.
It brings records from current client. In result structure/table there is no CLIENT field.
With CLIENT SPECIFIED the result set includes records from all the clients and result includes CLIENT field.
With CLIENT SPECIFIED and CLIENT field specified, the result set includes records from all the clients and also where condition can be applied on the CLIENT field.
If client handling type- #CLIENT_DEPENDENT then at least one of the data source must be client dependent.
If client handling type- #CLIENT_INDEPENDENT then all the data source(s) must be client independent. But here we have client dependent data source and it leads to activation error.