Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Bypass cardinality or eliminate duplicates.

tleonenko
Discoverer
0 Kudos
799

So for a new CDS view I'm making, there is a customer as a field. Some of these customer fields are empty, but I can use an association to I_SalesDocument on AssignmentReference, and if both CDS views have the same AssignmentReference, then the SoldToParty in the I_SalesDocument can be used for the customer in the new CDS view. The problem is that there are many different rows in I_SalesDocument with the same AssignmentReference, so I get many duplicates (and the two CDS views do not share a key or column with unique values). The thing is that I only need 1 row from I_SalesDocument, as the SoldToParty will be the same among rows with the same AssignmentReference. So I either need a way to force the association to just choose 1 row, or eliminate the duplicates I get.
Thank you for the help.

This is the relevant code:

Association:
association[0..1] to I_SalesDocument as _I_SalesDocument on _I_SalesDocument.AssignmentReference = DocumentReferenceID

and _I_SalesDocument.SalesDocumentType = 'ZSER'

and AccountingDocumentType = 'AB'


Column:
case

when

(ACDOCACustomer = '0000000000' or ACDOCACustomer is null or ACDOCACustomer = '')

and (DocumentReferenceID like 'E0%')

and (DocumentReferenceID = _I_SalesDocument.AssignmentReference)

then _I_SalesDocument.SoldToParty

else ACDOCACustomer

end as ACDOCACustomer,

1 REPLY 1

AndreaUS
Product and Topic Expert
Product and Topic Expert
0 Kudos
660