Skip to Content
-1

Count of n cardinality association in ABAP CDS

Mar 25, 2017 at 05:04 PM

212

avatar image
Former Member

Hi,

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
0

Hi,

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

Share
10 |10000 characters needed characters left characters exceeded