Skip to Content
-1

Count of n cardinality association in ABAP CDS

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 29, 2017 at 09:36 AM

    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

    Add comment
    10|10000 characters needed characters exceeded