Skip to Content

ABAP CDS view header table is joined with item table - header records are getting doubled up

Hi All,

I am trying to get the count of distinct credit memo based on Header table, when I join the same to item table values becomes as much time the items are there.

Below is the code which works fine when used on cds view created on top of VBRK

@DefaultAggregation: #SUM

case when vbtyp = 'O'or vbtyp = 'K' then

count (distinct vbrk.vbeln) else 0

end as Credit_memo_count

When the above view having above calculation is joined with item view on (VBRP)

credit memo count becomes as many times the items are there for a billing document.

I have tried multiple things like -

1) Exception aggregation of Credit_memo_count w.r.t to billing document (and do not take item in the output)

2) Calculating the above scenario after the join .. VBRP left outer join with VBRK but it works only when I do not select the Item field.

My question is why the count distinct doesn't consider distinct values of header and then what is the workaround for this.

Please suggest if you have come across such scenario and was able to overcome the same.


Regards,

Mayank

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers