In my program, I use BAPI_MATERIAL_AVAILABILITY to get the <u><b>on-hand quantity in CSE.</b></u>
The following is my code:
CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
plant = I_ZDAILY_MVMT-WERKS
material = I_ZDAILY_MVMT-MATNR
unit = 'CSE'
av_qty_plt = bapi_onhand
return = return
wmdvsx = atp1
wmdvex = atp2.
IF return IS INITIAL.
READ TABLE atp2 WITH TABLE KEY bdcnt = 0
req_date = sy-datum
com_date = sy-datum.
IF atp2-com_qty <> '9999999999.000'.
I_ZDAILY_MVMT-ONHAND_VAL = atp2-com_qty.
I_ZDAILY_MVMT-ONHAND_VAL = bapi_onhand.
The problem is that if the commented section above is uncommented, i get extremely large and unreliable data (for example 163,333,333,333,333 - which doesn't make sense.)
On the other hand, when the commented sections are left commented, i get data that seems real.
Which is the right way and what am i doing wrong? How do i check if the data that i am getting is correct?
Responses will be rewarded and highly appreciated