AGGREGATION ON CDS VIEW and Filtering data with where clause issue

Hi,

We have following case where in we have internal table data say ITAB (fields: matnr, werks) from previous CDS and lgort (Storage loc.) on selection screen

Now, Need to get SUM of stock (MARD-LABST) at matnr level.

meaning fetch from MARD based on ITAB matnr, werks, selection screen lgort and then SUM LAST as well.

tried by creating 2 CDS view as below it doesn’t filter based on ‘For all entries’ where condition ( even hardcoded values doesn’t work). it sums LABST for all werks and lgort. expectation is it should SUM only where clause matnr, werks and selection screen lgort.

___________________________________

matnr, werks,lgort,labst->CDS1

matnr, SUM(labst) group by matnr–>CDS2 ( select from CDS1..meaning calling CDS1 in CDS2)

Program:

Select matnr, stock
from CDS2
Inner join CDS1 on CDS2.matnr = CDS1.matnr
For all entries of ITAB where CDS1.matnr = itab-matnr
and CDS1.werks = itab-werks
and CDS1.lgort in select options of selection screen

_______________________________________

what I understood is while calling CDS2 aggregation already happened before where clause consideration which is in program and using werks and lgort in where clause doesn’t work or filter…but it filers by matnr as matnr is in both CDS views.

 

Any suggestion here?

Scroll to Top