Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_MATERIAL_AVAILABILITY returns different ATP quantity than CO09

mihailo_sundic
Active Contributor
0 Likes
2,720

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

1 ACCEPTED SOLUTION
Read only

mihailo_sundic
Active Contributor
0 Likes
1,315

I used a different type of ATP check, althow we use 'A' in sales orders, but '03' was just what i wanted.

Cheers.

2 REPLIES 2
Read only

mihailo_sundic
Active Contributor
0 Likes
1,315

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.

Read only

mihailo_sundic
Active Contributor
0 Likes
1,316

I used a different type of ATP check, althow we use 'A' in sales orders, but '03' was just what i wanted.

Cheers.