MMBE - Check the stock at the
various storage location
To change the Stock Overview:Basic List
-
Goto transactions OMBG - Rules for Stock Balance Display
The default Display version for MMBE is 1, you can define
additional version if required.
You can run this program (ZMMBE) if the user want to check
whether the Total Stock on hand quantity is correct. The program
will retrieve the previous month closing balance and add or subtract every
material movement from start to end of the month.
Check Quantity on hand shown by MMBE
* MMBE - Material Movements
* Retrieve the previous month closing balance
* Calculate the daily movements from start to end of
month.
* Verify that the Stock on hand figures shown in transaction
MMBE is
* correct.
report zmmbe line-size 170 no standard page heading
line-count 058(001).
tables: s031,
mkpf,
mseg.
data: begin of int_mseg occurs 100,
budat like mkpf-budat,
"posting date in the document
usnam like mkpf-usnam,
"user name
mblnr like mseg-mblnr,
"material document
bwart like mseg-bwart,
"movement type
grund like mseg-grund,
"reason for movement
lgort like mseg-lgort,
"storage location
matnr like mseg-matnr,
"material no.
aufnr like mseg-aufnr,
"production order number
ebeln like mseg-ebeln,
"purchase order number
ebelp like mseg-ebelp,
"purchase order item
menge(7) type p decimals
4, "quantity
meins like mseg-meins,
"unit of measure
werks like mseg-werks.
"plant
data: end of int_mseg.
data: x_werks like mseg-werks,
x_matnr
like mseg-matnr,
x_budat
like mkpf-budat,
t_bal
like s031-mzubb,
ttmenge(7)
type p decimals 4 value 0.
data: fdate like sy-datum,
ldate like sy-datum,
sdate like sy-datum.
data: nohead(1).
select-options date for mkpf-budat.
select-options t_matnr for mseg-matnr matchcode object
mat1.
select-options plant for mseg-werks.
parameters p_nohead as checkbox.
select * from mkpf where budat in date.
select * from mseg where mblnr = mkpf-mblnr
and mjahr = mkpf-mjahr.
check plant.
check t_matnr.
perform get_mseg.
endselect.
endselect.
* werks - plant
* bwart - movement type
* lgort - storage location
* budat - posting date
sort int_mseg ascending by werks matnr budat lgort bwart.
loop at int_mseg.
if x_werks is initial.
x_werks =
int_mseg-werks.
x_matnr =
int_mseg-matnr.
x_budat =
int_mseg-budat.
perform open_rtn.
endif.
if x_werks <> int_mseg-werks
or
x_matnr <>
int_mseg-matnr or
x_budat+(6)
<> int_mseg-budat+(6).
perform prn_grd.
x_werks =
int_mseg-werks.
x_matnr =
int_mseg-matnr.
x_budat =
int_mseg-budat.
perform open_rtn.
endif.
format color col_group.
write: / int_mseg-bwart
under 'Mvt',
int_mseg-budat under 'Post Date',
int_mseg-matnr under 'Material',
int_mseg-menge using edit mask 'RRV________.____'
right-justified under 'Qty Delv',
int_mseg-meins under 'Unit',
int_mseg-mblnr under 'Doc no',
int_mseg-werks(3) under 'Plt',
int_mseg-lgort under 'Sloc',
int_mseg-aufnr under 'Order',
int_mseg-ebeln under 'Pur Order',
int_mseg-ebelp under 'Item',
int_mseg-usnam under 'Create by'.
add int_mseg-menge to ttmenge.
endloop.
perform prn_grd.
form get_mseg.
if mseg-shkzg = 'H'.
multiply mseg-menge
by -1.
multiply mseg-dmbtr
by -1.
endif.
int_mseg-budat = mkpf-budat.
int_mseg-mblnr = mkpf-mblnr.
int_mseg-usnam = mkpf-usnam.
int_mseg-bwart = mseg-bwart.
int_mseg-grund = mseg-grund.
int_mseg-lgort = mseg-lgort.
int_mseg-matnr = mseg-matnr.
int_mseg-aufnr = mseg-aufnr.
int_mseg-ebeln = mseg-ebeln.
int_mseg-ebelp = mseg-ebelp.
int_mseg-menge = mseg-menge.
int_mseg-meins = mseg-meins.
int_mseg-werks = mseg-werks.
append int_mseg.
clear int_mseg.
endform.
form open_rtn.
new-page.
sdate = x_budat.
sdate+6(2) = '01'.
sdate = sdate - 1.
clear s031.
clear t_bal.
select * from s031 where werks = x_werks
and matnr = x_matnr.
t_bal = t_bal + s031-mzubb - s031-magbb.
if s031-spmon = sdate+(6).
s031-beszug = t_bal.
exit.
endif.
endselect.
write: / 'Opening Balance for ',
s031-spmon,
s031-werks,
s031-matnr,
s031-beszug.
skip.
add s031-beszug to ttmenge.
endform.
form prn_grd.
uline.
format color col_total.
write: / 'Stock on hand ',
ttmenge using edit mask 'RRV________.____'
right-justified under 'Qty Delv'.
skip.
clear ttmenge.
endform.
top-of-page.
format color col_total.
if p_nohead <> 'X'.
write: / sy-datum, sy-uzeit, sy-repid,
sy-uname,
'Transaction MMBE - Material Movement',
sy-pagno.
skip.
write: / 'Selection : '.
loop at date.
write:
'Date from ', date-low, ' to ', date-high.
endloop.
loop at plant.
write:
' Plant from ', plant-low, ' to ', plant-high.
endloop.
skip.
endif.
if nohead <> 'X'.
write: /1 'Mvt',
5 'Post Date',
16 'Material',
32 'Qty Delv',
48 'Unit',
53 'Doc no',
63 'Plt',
67 'Sloc',
72 'Order',
83 'Pur Order',
94 'Item',
100 'Create by'.
uline.
if p_nohead = 'X'.
nohead = 'X'.
endif.
endif.
initialization.
ldate = sy-datum.
ldate+6(2) = '01'.
ldate = ldate - 1.
fdate = ldate.
fdate+6(2) = '01'.
move: fdate
to date-low,
ldate to date-high.
append date.
SAP MM Reference Books:
SAP Material
Management Interview Questions, Certification and Configuration Books
Goto:
SAP MM Purchasing
Back to:
SAP MM (Materials Management)
Configuration Hints and Tips
Return to :-
SAP ABAP/4 Programming,
Basis Administration, Configuration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies. The site www.gotothings.com is in no way affiliated with
SAP AG.
Any unauthorised copying or mirroring is prohibited.
|