11-04-2004 12:29 AM
Hi all, i am working with SD module, and i need to create one report to show the real available stock, what's this:
We have the T Code MMBE, here you input the material number and show all the storage location with available stock, but don't show you the real available stock, example,
Material PHUY4578
Stock 10000
If i double click on some part of the display it show me a lot of info, like open orders, qc qty, Schd.for deliver, etc. The point here is that i don't get the real stock, using the example, i have this:
Schd.for deliver 5900
Here i see that my real stock qty is 4100, this is the data i need to get, we have the T Code MD04 is good but you need to input material by material, we need a lot of time.
My report need to display:
Customer, Material Unrestricted use Real stock, open delivery's, qty of each delivery, and some other information that i can get went i receive the principal data.
My solution is to get the Unrestricted use data, then search all the sales orders for each material they input, then check if each item is already completed, this with all the data i receive, and then see which items are open. But i see that is a lot of work, i was wondering is there is a better way.
I have vbak, vbap, lips, likp, vbfa to work with.
My other way is on my report use the tcode MD04 because this one has the info i need, but i don't know if its possible to useit? and how?
This is my situation, if some has a better way i will apreciate. Thanks for your time.
11-04-2004 12:51 PM
11-04-2004 1:12 PM
Hi,
Use BAPI_MATERIAL_AVAILABILITY to get the info.....
Cheers
colin.
11-04-2004 7:52 PM
Hi Simeone Gianluca, look here in our company dont use the table MSKU, it has 0 entrys.
Collin i think this BAPI use the table VBBE, is great because, the TCode MD04 has the info i need but, we need to input material by material.
The problem, is that i need lo learn how to use BAPI, but no problem iam searching for some tutorials.
Thanks all for your comments.
Starting BAPI knowledge...
11-16-2005 12:29 PM
Hi. Alberto.
Did you find any kind of documentation about?.
I'm also interested in using this function but I didn't find anything more else that on-line help.
Thanks in advance.
11-16-2005 12:46 PM
Hi Alberto,
The following FM code will help you in your requirement.
Regards,
Raj
FUNCTION ZMM_OPBAL_QTY_BASED_KEYDATE.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(I_MATNR) LIKE MARA-MATNR
*" REFERENCE(I_PLANT) LIKE T001W-WERKS
*" REFERENCE(I_KEYDT) LIKE BSIM-BUDAT
*" EXPORTING
*" REFERENCE(E_STK_OPBAL) LIKE BSIM-MENGE
*" REFERENCE(E_STK_VAL) LIKE BSIM-DMBTR
*"----
DATA : V_STK_OPBAL LIKE BSIM-MENGE,
V_STK_VAL LIKE BSIM-DMBTR,
V_KEYDT LIKE BSIM-BUDAT.
DATA : BEGIN OF IT_BSIM OCCURS 0,
MATNR LIKE BSIM-MATNR,
SHKZG LIKE BSIM-SHKZG,
MENGE LIKE BSIM-MENGE,
DMBTR LIKE BSIM-DMBTR,
END OF IT_BSIM.
DATA: BEGIN OF IT_MARD OCCURS 0,
MATNR LIKE MARD-MATNR, " Material
LABST LIKE MARD-LABST, " Unrestricted
END OF IT_MARD.
TYPES: BEGIN OF ST_MSEG,
MATNR LIKE MSEG-MATNR,
SHKZG LIKE MSEG-SHKZG,
MENGE LIKE MSEG-MENGE,
DMBTR LIKE MSEG-DMBTR,
BWART LIKE MSEG-BWART,
LGORT LIKE MSEG-LGORT,
END OF ST_MSEG.
DATA : IT_MSEG TYPE ST_MSEG OCCURS 0 WITH HEADER LINE,
TMP_MSEG TYPE ST_MSEG OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF IT_MBEW OCCURS 0,
MATNR LIKE MBEW-MATNR,
LBKUM LIKE MBEW-LBKUM,
SALK3 LIKE MBEW-SALK3,
END OF IT_MBEW.
V_KEYDT = I_KEYDT + 1.
SELECT MATNR
SHKZG
SUM( MENGE )
SUM( DMBTR )
INTO TABLE IT_BSIM
FROM BSIM
WHERE MATNR EQ I_MATNR
AND BWKEY EQ I_PLANT
AND BUDAT GE V_KEYDT
AND BLART IN ('RE','WE','WA','PR')
GROUP BY MATNR SHKZG.
SELECT MATNR
SUM( LBKUM )
SUM( SALK3 )
INTO TABLE IT_MBEW
FROM MBEW
WHERE MATNR EQ I_MATNR
AND BWKEY EQ I_PLANT
AND VPRSV EQ 'V'
AND BWTAR EQ ''
GROUP BY MATNR VPRSV.
SELECT MATNR
SUM( LABST )
INTO TABLE IT_MARD
FROM MARD
WHERE MATNR EQ I_MATNR
AND WERKS EQ I_PLANT
GROUP BY MATNR LABST.
SELECT A~MATNR
A~SHKZG
SUM( A~MENGE )
SUM( A~DMBTR )
A~BWART
A~LGORT
INTO TABLE IT_MSEG
FROM MKPF AS B
JOIN MSEG AS A
ON BMBLNR EQ AMBLNR
AND BMJAHR EQ AMJAHR
WHERE A~MATNR EQ I_MATNR
AND A~WERKS EQ I_PLANT
AND A~KZBEW IN (' ','B')
AND A~BWART NOT IN ('541','542','321','322','121')
AND A~KZVBR NOT IN ('A')
AND B~BUDAT GE V_KEYDT
GROUP BY AMATNR ASHKZG ABWART ALGORT.
LOOP AT IT_MSEG WHERE BWART EQ '544' AND LGORT EQ ''.
TMP_MSEG = IT_MSEG.
APPEND TMP_MSEG.
ENDLOOP.
DELETE IT_MSEG WHERE ( BWART EQ '309' AND DMBTR EQ 0 ).
DELETE IT_MSEG WHERE ( BWART NE '543' AND LGORT EQ '' ).
LOOP AT TMP_MSEG.
IT_MSEG = TMP_MSEG.
APPEND IT_MSEG.
ENDLOOP.
READ TABLE IT_MBEW WITH KEY MATNR = I_MATNR.
IF SY-SUBRC = 0.
V_STK_OPBAL = IT_MBEW-LBKUM.
V_STK_VAL = IT_MBEW-SALK3.
ELSE.
*- If Read on MBEW fails, Get data from IT_MARD
READ TABLE IT_MARD WITH KEY MATNR = I_MATNR.
IF SY-SUBRC = 0.
V_STK_OPBAL = IT_MARD-LABST.
ENDIF.
ENDIF.
LOOP AT IT_MSEG.
IF IT_MSEG-SHKZG EQ 'S'.
V_STK_OPBAL = V_STK_OPBAL - IT_MSEG-MENGE.
ELSE.
V_STK_OPBAL = V_STK_OPBAL + IT_MSEG-MENGE.
ENDIF.
ENDLOOP.
LOOP AT IT_BSIM.
IF IT_BSIM-SHKZG EQ 'S'.
V_STK_OPBAL = V_STK_OPBAL - IT_BSIM-MENGE.
V_STK_VAL = V_STK_VAL - IT_BSIM-DMBTR.
ELSE.
V_STK_OPBAL = V_STK_OPBAL + IT_BSIM-MENGE.
V_STK_VAL = V_STK_VAL + IT_BSIM-DMBTR.
ENDIF.
ENDLOOP.
E_STK_OPBAL = V_STK_OPBAL.
E_STK_VAL = V_STK_VAL.
ENDFUNCTION.
10-13-2008 7:17 AM