Thursday, 27 February 2020 11:57

Filtering data in association with [n..*] cardinality

Written by https://blogs.sap.com/2020/02/28/filtering-data-in-association-with-n..-cardinality/
Rate this item
(0 votes)

Introduction

One of the limitation with association in ABAP CDS view is we cannot use association field in where condition if the maximum cardinality of the association is n ( association[n.

.*] ).

Scenario

In the below example, a basic view on TFK003 (Document types) master data table is being created with association to its text table TFK003T.  As the cardinality of the association is defined as [1..*], use of where condition on language field spras to restrict to session language results in below error

“To many” associations (cardinality [n..*]) are not allowed here

Alternative way is creating a new basic view for text table TFK003T with filter on language and using that new basic view for association which leads to extra effort.

To overcome this, we can use path expression on association name to filter out data as shown below:

Output:

Conclusion

The above approach is straight forward and will cut down the effort.

Note:

Similar approach can be used with any pair of tables with 1:n relationship to filter out data but care should be taken as the association with filter path expression can modify the cardinality of the results set.

Read 47 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.