Skip to Content
Former Member
Aug 18, 2017 at 08:18 AM

ABAP CDS view not returning correct result for difference of two fields

606 Views Last edit Aug 18, 2017 at 11:02 AM 2 rev


We have defined a CDS view ZOPEN_ORDERS (with some parameters) on VBAK/VBAP/VBFA/VBUP and MSEG tables to get the summarized delivery quantities and stock in transit for all materials . Result returned is like:

Material(MATNR) Delivery Quan(RFMNG) In transit (MENGE)
Mat1 100 20
Mat2 200 0

On top of this we have created another view to return the difference of the two columns RFMNG and MENGE as below:

define view ZOP_DDL with parameters
iv_werks : werks_d,
iv_atpchk : flaf,
iv_unres : flag,
iv_rw_stock : flag

as select from ZOPEN_ORDERS_DDL( iv_werks : $parameters.iv_werks , iv_atpchk : $parameters.iv_atpchk , iv_unres : $parameters.iv_unres , iv_rw_stock : $parameters.iv_rw_stock )

{ matnr,
rfmng as rfmng,
rfmng - ( cast (menge as abap.quan(15,3) ) ) as labst_pm,
rfmng - menge as labst_org }

The problem is that the second view does not return the difference of RFMNG and MENGE . Both LABST_ORG and LABST_PM are zero if MENGE is zero . Otherwise the result is correct.

Mat1 100 20 80 80
Ma2 200 0 0 0

Appreciate any help in this regard.

Thanks in advance!