Application Development 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: 

Return the ATP Situation table from CO09

Former Member
0 Kudos

I'm looking for a function that will return the ATP Situation table of CO09 (Availablity Overview).  I have built some prototype code using BAPI_MATERIAL_AVAILABILITY, but so far have only been able to retrieve one line per material/plant (the ATP Stock) with a date from it.  When I enter a material, plant, checking rule, and select "With Reqmts qtys", I want a FM to return the ATP Situation table that is displayed.

I've read other posts on possibly using ATP_CALCULATE_MDPS or ATP_CHECK_BASIS to do this, but I've been unable so far to determine what values are necessary in the input of those FMs to get them to return anything.

Any ideas on a FM that I can use, or a good spot to breakpoint in the CO09 code flow, to determine FM input values?

Ultimately, my goal is to loop over whatever function I can use to build a table of the ATP Situation data for all the materials.  (It's for a data load to the BW system).

Thanks in advance.

6 REPLIES 6

Former Member
0 Kudos

I'm taking the time to fill in some gaps with this question.  It took some digging, but I found the function Function Module that I need on my own.  It is "Availability Check".  When you pass the material number, plant and UofM in the p_atpcsx table) the function returns a table that represents the ATP Situation table in the lower portion of the CO09 screen.

The Co09 screen shows the Quantity Received or quantity required values in the orders as negative values (thus reducing the Cum. ATP qty).  The FM Availability_Check doesn't return these values as negative, however.  Can anyone tell me if there is a flag or some other way to determine through Availability_Check whether the values should be negative.  Also does CO09 calculate the Cum. ATP qty as a running total, or is that Cumulative value available as a returned value somewhere, as well?  I'd rather use the correct returned values for these, if I can, if they are available.

Former Member
0 Kudos

I'm still hoping to hear from some one with this question and get some help.  I have found one of the core function mods of CO09 (Availability_Check) but I debugged CO09 and as it continues past that FM, it calculates the cumulative ATP qty (right-most column) well after the FM

Availability_Check.

I need my new function to return the cumulative ATP qty for my material / plant combo as well.  There is lots of logic in the CO09 flow as it fills up the resulting MDEZX table. Eventually in the flow of CO09, That internal table has the cumulative ATP quantity that I need (MDEZ-MNG04) but I don't think it would be easy to copy all of the logic it has to get the cumulative ATP qty.  Is there another (or a different FM that will accomplish this?  I need to return basically all columns that CO09 shows except Confirmed Qty.

Important note:   I'm using the With Reqmts qtys checkbox in CO09.  I think this equates to TMVF-ONVBA = 3 (at least it appears that way in debug in CO09).

Thanks in advance

0 Kudos

Hi Jeremy

Did you get chance to find anything on how to do this? I am in same situation like you, trying to find out the same.

Thx,

Nagesh

0 Kudos

Hello Nagesh,

Unfortunately, I never got an answer or a method/function that does 100% of what I wanted.  The client changed their mind anyway, at my location, and they didn't want this requirement after all, so I dropped it.

There are several FMs that could be used, though none do exactly what I wanted.  The last challenge I had before I stopped was that I had all the lines from the CO09 coming back per material, but they weren't aggregating in the same way as the screen (running total style).

The client also wanted only one of the storage locations to be used on the extract (which of course is slightly *different* than Co09.

I would be glad to share my notes with you, if you are still interested of the functions that tried.

Regards,

Jeremy H.

0 Kudos

Hi Jeremy and Nagesh.

I know it's been several years but I'd like to see the notes.

Nagesh, did you have eventual success with a solution?

Wayne

Former Member
0 Kudos

I eventually ended up using the standard function module AVAILABILITY_CHECK.  My requirements changed such that I didn't need code that exactly replicated what Co09 does, but instead the ATP as of a certain date (comparable to a row from Co09).

Given an internal table of it_request_item (which consists of MATERIAL, REQUESTDATE and PLANT), consider the following code:

   LOOP AT it_request_item INTO wa_request.

     dt_atpcs-matnr = wa_request-material.

     dt_atpcs-werks = wa_request-plant.

     dt_atpcs-prreg = 'A'.

     dt_atpcs-chmod = 'EXP'.

     dt_atpcs-delkz = 'VC'.

     dt_atpcs-bdter = wa_request-requestdate.

     dt_atpcs-xline = 1.

     dt_atpcs-trtyp = 'H'.

     dt_atpcs-idxatp = 1.

     dt_atpcs-resmd = 'X'.

     dt_atpcs-chkflg = 'X'.

     APPEND dt_atpcs.

     CLEAR dt_atpcs.

   MOVE:

      'A' TO ds_atpca-rdmod,

      'T'   TO ds_atpca-azerg,

      'N'   TO ds_atpca-xenqmd,

      '8'   TO ds_atpca-anwdg,

      'A' TO ds_atpca-anwdg_orig.

     CALL FUNCTION 'AVAILABILITY_CHECK'

       TABLES

         p_atpcsx    = dt_atpcs

         p_atpcsx_r3 = dt_atpcs_r3

         p_atpdsx    = atpdsx

         p_atpmatx   = atpmatd

       CHANGING

         p_atpca     = ds_atpca

       EXCEPTIONS

         error       = 1

         OTHERS      = 2.