‎2012 Jan 28 8:53 AM
I'm using the following code to get ATP quantity of material, it returns (field: AV_QT_PLT = d_WKBST) the current stock quantity (it doesn't subtract orders and deliveries from that quantity). I need to get a return value from BAPI which value is as "Cummulative ATP quantity" from CO09.
You can see in my code which parameters i used to get the value - CHECK_RULE is 'A' etc.
I take the value: BAPICM61V-WKBST as my return value - maybe i need to take some other value to get what i need (cummulative ATP quantity)?
REPORT Z_ATP_CUMMULATIVE.
Parameter: p_matnr like BAPIMATVP-MATNR,
p_werks like BAPIMATVP-WERKS default 'AR01' obligatory,
p_unit like BAPIADMM-UNIT.
*Data: int_wmdvsx like BAPIWMDVS occurs 0 with header line,
* int_wmdvex like BAPIWMDVE occurs 0 with header line.
Data: int_wmdvsx type table of bapiwmdvs with header line,
int_wmdvex type table of bapiwmdve with header line,
d_WKBST like BAPICM61V-WKBST.
CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
EXPORTING
PLANT = p_werks
MATERIAL = p_matnr
UNIT = p_unit
CHECK_RULE = 'A'
* STGE_LOC =
* BATCH =
* CUSTOMER =
* DOC_NUMBER =
* ITM_NUMBER =
* WBS_ELEM =
* STOCK_IND =
* DEC_FOR_ROUNDING =
* DEC_FOR_ROUNDING_X =
* READ_ATP_LOCK =
* READ_ATP_LOCK_X =
IMPORTING
* ENDLEADTME =
AV_QTY_PLT = d_WKBST
* DIALOGFLAG =
* RETURN =
TABLES
WMDVSX = int_wmdvsx
WMDVEX = int_wmdvex
.
Write:/ d_WKBST.
If sy-subrc = 0.
endif.Edited by: mihailosundic on Jan 28, 2012 9:54 AM
SOLVED:
OK i have found the issue, i just needed to take the value from my table: int_wmdvex and field is: COM_QTY
I have the same value as cumm.ATP qty from CO09.
Edited by: mihailosundic on Jan 28, 2012 10:03 AM
‎2012 Feb 18 9:56 PM
I used a different type of ATP check, althow we use 'A' in sales orders, but '03' was just what i wanted.
Cheers.
‎2012 Feb 11 7:02 PM
One problem has occured in results of my ATP report.
When i have a production order for 20.000 pcs for one material, and i have 500 pcs on stock for the same material, and i have no sales orders or deliveries, com_qty returns the value of the production order = 20.000 pcs.
My ATP should be 20.500 as i have 500 on stock and 20.000 pcs that will be produced in 5 days, but it shows only 20.000 pcs.
Does it have something to do with not passing requirements date? If it has, how do i pass that date to BAPI (i can't see that value in exporting part of the function)?
It would be good to have possibility to get the ATP based on quantities that are on stock (without production orders quantities), and also quantity based on both stock and production orders. (i might implement a check-box for including production order quantities and a requirements date field that will be passed to BAPI).
Please, if there are any suggestions on any problem feel free to help.
Thanks in advance.
‎2012 Feb 18 9:56 PM
I used a different type of ATP check, althow we use 'A' in sales orders, but '03' was just what i wanted.
Cheers.