‎2008 Apr 30 5:47 AM
How is it possible to know the free stock available for a given material in this function module.
I have no idea how to use this module.
Sombody Plz help....
Thanks All..
‎2008 Apr 30 7:52 PM
Hi,
Follow an example bellow, obtained from http://sapfans.com/forums/viewtopic.php?t=187787:
&----
*& Form determine_mat_avail
&----
Call the FM AVAILIBILITY_CHECK to find the ATP Qty and Qty
Received
----
-->P_MATNR Material
-->P_WERKS Plant
<--P_QTY ATP Qty
<--P_QTY_O Qty Received
<--P_MEINS Base UoM
----
form determine_mat_avail using p_matnr
p_werks
changing p_qty
p_qty_o
p_meins.
Structure to hold ATP Controller: Control Parameters
data: begin of st_atpca.
include structure atpca.
data: end of st_atpca.
Table to hold ATP: Requirements to be Checked/Considered
data: begin of tbl_atpcs occurs 0.
include structure atpcs.
data: end of tbl_atpcs.
Table to hold ATP Server: ATP data for display
data: begin of tbl_atpds occurs 0.
include structure atpds.
data: end of tbl_atpds.
Table to hold ATP Server: Material Table
data: begin of tbl_atpmat occurs 0.
include structure atpmat.
data: end of tbl_atpmat.
Populate ST_ATPCA
clear st_atpca.
st_atpca-anwdg = '8'. "Calling App - Explaination
st_atpca-azerg = 'T'. "ATP Display Result
st_atpca-rdmod = 'A'. "Read Mode - Totals
st_atpca-xenqmd = 'N'. "Do not read Blocks
Populate TBL_ATPCS
clear tbl_atpcs.
refresh tbl_atpcs.
tbl_atpcs-matnr = p_matnr. "Material
tbl_atpcs-werks = p_werks. "Plant
tbl_atpcs-prreg = 'A'. "Checking Rule for Avail Check
tbl_atpcs-chmod = 'EXP'. "ATP: Check mode
tbl_atpcs-delkz = 'VC'. "MRP element indicator
tbl_atpcs-bdter = sy-datum. "Requirements date for the component
tbl_atpcs-xline = '1'.
tbl_atpcs-trtyp = 'A'. "Transaction type - Display
tbl_atpcs-idxatp = '1'.
tbl_atpcs-resmd = 'X'. "Mode for Results of Check - Proposal
tbl_atpcs-chkflg = 'X'.
append tbl_atpcs.
call function 'AVAILABILITY_CHECK'
tables
p_atpcsx = tbl_atpcs
p_atpdsx = tbl_atpds
p_atpmatx = tbl_atpmat
changing
p_atpca = st_atpca
exceptions
error = 1
others = 2.
check sy-subrc eq 0.
read table tbl_atpds with key delkz = 'WB'. "Plant Stock
if sy-subrc eq 0.
tbl_mat_avail-matnr = p_matnr.
tbl_mat_avail-werks = p_werks.
tbl_mat_avail-qty = tbl_atpds-qty.
tbl_mat_avail-qty_o = tbl_atpds-qty_o.
Get the Base UoM
read table tbl_atpmat with key matnr = p_matnr.
if sy-subrc eq 0.
tbl_mat_avail-meins = tbl_atpmat-meins.
p_meins = tbl_atpmat-meins.
endif.
insert table tbl_mat_avail.
p_qty = tbl_atpds-qty.
p_qty_o = tbl_atpds-qty_o.
endif.
endform. " determine_mat_avail
*----
Good lucky!
‎2011 Jul 13 9:50 PM
And in a nutshell, for the fun of it:
Minumum of variables to be filled for checking the availability of a material on a certain date.
P_ATPCSX-MATNR = material code (no need to fill it out).
P_ATPCSX-WERKS = plant code.
P_ATPCSX-PRREG = check rule A = Sales Order, B = Delivery, BO = backorder.
P_ATPCSX-BDTER = date for requirement, for example sy-datum.
P_ATPCSX-IDXATP = sequence for ATP-check if you want to combine it with a check against Planning or against Contingencies. If you only need an ATP-check then an 1 here will suffice.
P_ATPCSX-CHKFLG = X. The BDMNG, required quantity must be checked in simulation (as opposed to: be taken in account while checking what's left...oslt)
You will find the total ATP-quantity in P_ATPCSX-ATPM1.
P_MDVEX can be filled by the FM with a list of availability dates, just as you may know from the ATP-dialog in the sales order, if you add these variables:
P_ATPCSX-BDMNG = required quantity.
P_ATPCSX-XLINE = should be filled as this is the reference to P_MDVEX-DBCNT, fill it with 10 for example.
P_ATPCSX-RESMD = This one determines the way P_MDVEX is filled!:
With regard to P_ATPCSX-RESMD:
Empty = One-time delivery on requested delivery date
A = Quantity at requested date, lock entire confirmation (Apparently useful for assembly orders, not so much in sales orders.)
B = Complete dlv. (System confirms on the first date that the total quantity can be deliverd, otherwise no confirmation.)
X = Proposal list. (Overview of the earliest dates on which (the complete or) parts of the required quantity can be delivered.)
Just for information:
(P_ATPCSX-IDXPLN = sequence for check against Planning 1, 2 or 3. 0 means this check will not be performed.)
(P_ATPCSX-IDXALL = sequence for check against Contingencies 1, 2 or 3. 0 means this check will not be performed.)
‎2008 Apr 30 8:15 PM
Hi Shashank,
yes you can......
the above code posted by another person works.i have also checked it. go a head with it
thanks
sagar
<REMOVED BY MODERATOR>
Edited by: sagar reddy on Apr 30, 2008 9:16 PM
Edited by: Alvaro Tejada Galindo on Apr 30, 2008 3:18 PM
‎2008 Apr 30 8:45 PM
Hi SHASHANK JAISWAL ,
Use the BAPI "BAPI_MATERIAL_AVAILABILITY".
Hope this helps.
Thanks,
Greetson