Skip to Content

Count of n cardinality association in ABAP CDS

Mar 25, 2017 at 05:04 PM


avatar image
Former Member


I want to count purchase order items for a particular purchase order. I have two ABAP CDS: one for purchase order and one for purchase order item. I can create a new cds which will select from purchase order and will have n cardinality association(1..*) to purchase order items cds. The output columns of final cds should be like:

PO Number NumberOfPOItems

Can any one suggest sample code for such CDS?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Christian Wolter Mar 29, 2017 at 09:36 AM


you can use the count and group by clause to achieve this.

define view y_test
as select from y_po_items
 key y_po_items.po_number
 count( y_po_items.item_number ) as NumberOfPOItems
group by y_po_items.po_number

I don't know your CDS-view, so you have to adopt this sample on your specific structure.

Best regards

Christian Wolter

10 |10000 characters needed characters left characters exceeded