Technical Articles
Duplicated records in custom CDS view in S4 hana cloud
In one of customer support case , custom create an custom cds view . They set delivery item cds as Primary Datasource , cds billing item as Associated Datasource with zero or one relation base on DN number and DN item . But in preview, delivery item duplicated which is not the expected result from customer .
The key is the understanding for Cardinality , customer think billing item has been set as 0::1 relation, so billing item always populate 0 or 1 record for one delivery item even though multi billing items exist for one delivery item(like dropship sales) . But the actual situation is relation between delivery item and billing item will be translated into 0::n relation in SQL select .
The following are the testing result in one SAP internal system . I will take sales order and sales order item as data source . There relation is 1 to N . But I will set the cardinality as 0::1 .
DataSources
Since the actual relation is 1 to n , system will give a alert when checking .
AlertForIncorrectCardinality
Sale order record duplicated in preview .
SaleDocumentDuplicatedInPreview
Hope this will help in understanding view relation in custom cds view .
Best regards!
Jacky Liu
Hi, Jens,
Thanks for your suggestion!
If we take sales order item as primary data source, it is correct practice .But the purpose of this blog is to show the wrong practice and explain the understanding of Cardinality . We always guide customer with correct practice. But customer will create custom cds view with their own understanding or bad practice .If the result is not expected , they will ask help from support center .
Best regards!
Jacky Liu
There are several whitelisted CDS views pre-delivered with SAP S/4HANA Cloud, which can be utilized to retrieve data from the SAP S/4HANA Cloud tenant.
SAP S/4HANA Cloud also provides user with the flexibility for creating their own custom CDS views, combining various whitelisted CDS views, to meet their specific requirement of retrieving data.
These custom CDS views can be easily exposed as OData Service (External API), which can then be utilized to fetch data from SAP S/4HANA Cloud.
myindigocard