2023 May 29 9:49 PM
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,
2023 May 30 9:22 AM
Maybe UNION DISTINCT (CDS DDL - CDS View Entity, SELECT, UNION)?
Or filter the association? CDS DDL - CDS View Entity, path_expr, cardinality