Opening Stock calculation
Hello Experts,
I am doing a report on Opening and closing stock with the subcontractors...
My report's requirement is..
Mat. No. - ekpo-matnr
Part No. - resb-matnr
Opeining stock (for Resb-matnr) - ( movement type 541542543+544 from Mseg)
Please advice me how to calculate opening stock for the Parts as ekpo-matnr is linked to ekbe-budat
and I have to take the opening stock by linking mkpf-budat. And for single material (ekpo-matnr)
there will be multiple part no (resb-matnr) and I want the openinig stock for each part no.
Please advice...your help would be highly appreciable.
Thanks
R.Karthik.
Hi Karthik,
Opening stock can be directly seen in LBKUM field, which is valuated stock.
this is available in MSEG, i am not sure how accurate it is,
and MBEWH, MARDH, MCHBH.
T.code:MB5B
& CKM3 Sometimes..
and check this link.
link: [ Opening Stock |
http://help.sap.com/bp_bblibrary/470/Documentation/J33_BPP_32_CHEM_EN_IN.doc ]
Best Regards ,
Dileep .C
Similar Messages
-
Opening Stock and Closing Stock Calculation
Hi,
My report requirement is to display the material, opening stock for the lower date, closing stock for the higher date and the in between all stock operations..how to fetch the opening stock and closing stock for a particular material ???.. what are the tables and fields for calculating them??..
Thanks,
Sri
Edited by: Sri on Feb 13, 2009 8:33 AMHi
We have done a similar reports. One showing opening stock/Closing stock and another one showing all the transactions for a particular day. What we did was we developed a program to fetch data from MARD table for unrestricted, blocked & Qulaity stock(Our requirement talks only about these 3 stocks). And we scheduled the program exactly at system time 00.00 hrs with A class job.(today's closing day stock is nothing but tomorrow's opening stock)
And for the second report which needs to pick all the transaction for a particular day, we picked it from MB51 entries. It is nothing but query between MKPF and MSEG.
I hope this helps. -
Opening Stock and Closing Stock fields and Calculation
Hi,
My report requirement is to display the material, opening stock for the lower date, closing stock for the higher date and the in between all stock operations..how to fetch the opening stock and closing stock for a particular material ???.. what are the tables and fields for calculating them??..
Thanks,
Srithis is the code i wrote..
I had selected the data for the date entered and the previous date(l_date) also..
previous date for the opening stock.
now i am getting only receipts and issues correctly.. opening stock and the remaining
balance fields are not coming properly..please help me..
here rmenge for receipts,imenge for issues.
REPORT ZSTOCK no standard page heading line-size 180.
types: begin of ty_date,
budat type budat,
end of ty_date,
begin of ty_mard,
matnr type matnr,
lgort type lgort_d,
labst type labst,
UMLME TYPE UMLMD,
INSME TYPE INSME,
EINME TYPE EINME,
SPEME TYPE SPEME,
RETME TYPE RETME,
end of ty_mard,
begin of ty_makt,
matnr type matnr,
maktx type maktx,
end of ty_makt,
begin of ty_mbew,
matnr type matnr,
bwkey type bwkey,
lbkum type lbkum,
salk3 type salk3,
end of ty_mbew,
begin of ty_mkpfmseg,
mblnr type mblnr,
budat type budat,
bwart type bwart,
matnr type matnr,
lgort type lgort_d,
shkzg type shkzg,
dmbtr type dmbtr,
menge type mseg-menge,
end of ty_mkpfmseg,
begin of ty_opstock,
matnr type matnr,
rdmbtr type dmbtr,
idmbtr type dmbtr,
bdmbtr type dmbtr,
bmenge type menge_d,
end of ty_opstock,
begin of ty_output,
mblnr type mblnr,
budat type budat,
matnr type matnr,
maktx type maktx,
bwart type bwart,
lgort type lgort_d,
shkzg type shkzg,
rmenge type mseg-menge,
rdmbtr type dmbtr,
imenge type mseg-menge,
idmbtr type dmbtr,
dmbtr type dmbtr,
bdmbtr type dmbtr,
bmenge type menge_d,
end of ty_output.
data: t_date type standard table of ty_date initial size 0,
t_mard type standard table of ty_mard initial size 0,
t_makt type standard table of ty_makt initial size 0,
t_mkpfmseg type standard table of ty_mkpfmseg initial size 0,
t_opstock type standard table of ty_opstock initial size 0,
t_out type standard table of ty_output initial size 0,
w_date type ty_date,
w_mard type ty_mard,
w_makt type ty_makt,
w_mkpfmseg type ty_mkpfmseg,
w_opstock type ty_opstock,
w_out type ty_output,
g_matnr type mara-matnr,
g_lgort type t001l-lgort.
selection-screen begin of block b1 with frame.
parameters:p_werks type t001l-werks obligatory memory id pw.
select-options:s_lgort for g_lgort no-extension no intervals.
select-options: s_matnr for g_matnr.
parameters:p_date type mkpf-budat obligatory.
selection-screen end of block b1.
at selection-screen.
perform sub_validate_date.
start-of-selection.
data: l_date type sy-datum,
l_row type i.
refresh t_date.
select budat from mkpf into table t_date.
sort t_date.
delete adjacent duplicates from t_date.
clear w_date.
read table t_date into w_date with key budat = p_date.
l_row = sy-tabix.
l_row = l_row - 1.
clear w_date.
read table t_date into w_date index l_row.
l_date = w_date-budat.
select k~mblnr
k~budat
s~bwart
s~matnr
s~lgort
s~shkzg
s~dmbtr
s~menge
into table t_mkpfmseg
from mkpf as k inner join mseg as s
on kmblnr = smblnr and
kmjahr = smjahr
where k~budat between l_date and p_date and
s~matnr in s_matnr and
s~werks = p_werks and
s~lgort in s_lgort.
if t_mkpfmseg is not initial.
sort t_mkpfmseg by budat ascending
matnr ascending.
select matnr
lgort
labst
umlme
insme
einme
speme
retme
from mard
into table t_mard
for all entries in t_mkpfmseg
where matnr = t_mkpfmseg-matnr and
werks = p_werks and
lgort in s_lgort.
select matnr
maktx
from makt
into table t_makt
for all entries in t_mkpfmseg
where matnr = t_mkpfmseg-matnr.
endif.
loop at t_mkpfmseg into w_mkpfmseg where budat = l_date.
loop at t_mard into w_mard where matnr = w_mkpfmseg-matnr.
w_opstock-matnr = w_mkpfmseg-matnr.
if w_mkpfmseg-shkzg = 'S'. " Receive
w_opstock-rdmbtr = w_mkpfmseg-dmbtr.
w_opstock-bmenge = w_mard-labst + w_mard-insme + w_mard-speme
+ w_mard-einme + w_mard-retme
- w_mkpfmseg-menge.
elseif w_mkpfmseg-shkzg = 'H'. " Issue
w_opstock-idmbtr = w_mkpfmseg-dmbtr.
w_opstock-bmenge = w_out-bmenge + w_mkpfmseg-menge.
endif.
w_opstock-bdmbtr = w_out-rdmbtr - w_out-idmbtr.
append w_opstock to t_opstock.
clear w_opstock.
endloop.
endloop.
loop at t_mkpfmseg into w_mkpfmseg where budat = p_date.
loop at t_mard into w_mard where matnr = w_mkpfmseg-matnr.
clear w_makt.
read table t_makt into w_makt with key matnr = w_mkpfmseg-matnr.
if sy-subrc = 0.
w_out-budat = w_mkpfmseg-budat.
w_out-matnr = w_mard-matnr.
w_out-maktx = w_makt-maktx.
w_out-lgort = w_mard-lgort.
w_out-mblnr = w_mkpfmseg-mblnr.
w_out-bwart = w_mkpfmseg-bwart.
w_out-shkzg = w_mkpfmseg-shkzg.
if w_mkpfmseg-shkzg = 'S'. " Receive
w_out-rmenge = w_mkpfmseg-menge.
w_out-rdmbtr = w_mkpfmseg-dmbtr.
w_out-imenge = 0.
w_out-bmenge = w_mard-labst + w_mard-insme + w_mard-speme
+ w_mard-einme + w_mard-retme
- w_mkpfmseg-menge.
elseif w_mkpfmseg-shkzg = 'H'. " Issue
w_out-imenge = w_mkpfmseg-menge.
w_out-idmbtr = w_mkpfmseg-dmbtr.
w_out-rmenge = 0.
w_out-bmenge = w_out-bmenge + w_mkpfmseg-menge.
endif.
w_out-bdmbtr = w_out-rdmbtr - w_out-idmbtr.
append w_out to t_out.
clear w_out.
endif.
endloop.
endloop.
write: / 'Material' , 12 'Description' ,40 'Location', 50 'Opening stock',70 'MvT',
83 'Receipts' , 102 'Issues', 118 'Amount',135 'Balance Quan', 155 'Balance Amount'.
loop at t_out into w_out.
write: / w_out-matnr, 12 w_out-maktx, 40 w_out-lgort.
clear w_opstock.
read table t_opstock into w_opstock with key matnr = w_out-matnr.
if sy-subrc = 0.
write: 45 w_out-bmenge.
endif.
write: 70 w_out-bwart,75 w_out-rmenge,92 w_out-imenge,
110 w_out-bdmbtr, 130 w_out-bmenge, 150 w_out-bdmbtr.
endloop.
*& Form SUB_VALIDATE_DATE
FORM SUB_VALIDATE_DATE.
select budat
from mkpf
into table t_date
where budat = p_date.
if t_date is initial.
message e001(zks) with 'select another date range'.
endif.
ENDFORM. " SUB_VALIDATE_DATE
Edited by: Sri on Feb 18, 2009 8:31 AM -
Opening and Closing Stock Calculation In SAP BPC 10.0 NW
Hello Experts,
Need your guidance on this calculation.
BI Cube: Receipts and Issues only Available on day basis
BPC Report / Cube Context
Product = Product1, Product2,
Account = receipts, Issues, Opening Stock, Closing stock,
Flow = Other
Audittrail = Input
UOM = QTY
rptcurrency = LC
Category = Actual
TIme = All Periods (Monthly)
Plant = Plant1, Plant2, Plant3, Plant4
In the Cube I don't Have Opening Stock, without Which I cannot calculate Closing stock.
Scenario: If I Enter Manually Opening stock for all products at some starting point, say In Year 2008 Jan. How To take this closing stock of this month automatically to next month opening stock and So on and so forth to following Periods? Is it possible through "Carry Forward Business rule" in this case, as Closing stock is a calculated value using Member dimension Formula. I am having receipts and issues in Account dimension.
Dimension Formula used: Closing Stock = Opening Stock+Receipts- Issues.
Please find attachment of the report screen shot.
Thanking you
PraveenHello Vadim,
1. The Cube storage Type is "Periodic".
2. Acctype of the account dimension is "AST"
3. Time Dimension Is based on Month.
ID
Description
RELEVANT
Base Period
CLOSED
Level
Month Number
Period
TIMEID
Year
Calendar
2006.01
2006 Apr
1
MONTH
1
APR
20060100
2006
2006.Q1
2006.02
2006 May
2
MONTH
2
MAY
20060200
2006
2006.Q1
2006.03
2006 June
3
MONTH
3
JUN
20060300
2006
2006.Q1
2006.04
2006 July
4
MONTH
4
JUL
20060400
2006
2006.Q2
2006.05
2006 August
5
MONTH
5
AUG
20060500
2006
2006.Q2
2006.06
2006 September
6
MONTH
6
SEP
20060600
2006
2006.Q2
2006.07
2006 October
7
MONTH
7
OCT
20060700
2006
2006.Q3
2006.08
2006 November
8
MONTH
8
NOV
20060800
2006
2006.Q3
2006.09
2006 December
9
MONTH
9
DEC
20060900
2006
2006.Q3
2006.10
2007 Jan
10
MONTH
10
JAN
20061000
2006
2006.Q4
2006.11
2007 Feb
11
MONTH
11
FEB
20061100
2006
2006.Q4
2006.12
2007 Mar
12
MONTH
12
MAR
20061200
2006
2006.Q4
2006.Q1
2006 Q1
3
QUARTER
3
Q1
2006
2006.TOTAL
2006.Q2
2006 Q2
6
QUARTER
6
Q2
2006
2006.TOTAL
2006.Q3
2006 Q3
9
QUARTER
9
Q3
2006
2006.TOTAL
2006.Q4
2006 Q4
12
QUARTER
12
Q4
2006
2006.TOTAL
2006.TOTAL
2006
12
YEAR
12
TOTAL
2006
Thank You
Praveen -
Hello Gurus,
I am using 0IC_C03 for stocks. Infosource 2LIS_03_BX, 2LIS_03_BF & 2LIS_03_UM is populating data to the cube.
How do I calculate Opening stock values. I need a column for displaying op. stock.
pls guide.
thanks in advance..Hi,
You can check business content query 0IC_C03_Q0012.
Just to be clear, you want to display opening stock (as on each day, or month, or ??).
I would think using the keyfigure 0TOTALSTCK (Total stock) or other such KF (for other categories of stocks) would do. System would do the calculation for you as I understand.
This may also help if you have not looked at it yet
<i>"How-to..." Paper for Inventory Management Scenarios in SAP BW: SAP offers a document dealing with the special features in implementing SAP BW in the Inventory Management area.
To display this document, in the SAP Service Marketplace (http://service.sap.com), select the Quick Link /bw, then choose SAP BW InfoIndex in the Navigation area and follow the Non-cumulatives link in the list. The document is named How to...Handle inventory management scenarios in SAP BW 3.x (pdf).</i>
cheers, -
Opening Stock and Closing Stock
Hi,
I have one requirement to get a opening stock and closing stock of all materials, based on the plant date and mat type.
Could u tell me the flow of tables one by one
Its is possible to get the opening stock and closing stock of all materials.
Please Guide Me.
Thanks & Regards,
Dhanush.S.Tgo through this....
*& Report Z_OPEN_CLOSE *
REPORT Z_OPEN_CLOSE MESSAGE-ID YW2 LINE-SIZE 231 LINE-COUNT 45
NO STANDARD PAGE HEADING.
Type Declaration *
TYPE-POOLS SLIS.
Tables *
TABLES: MKPF, " Material Document: Header Data
MSEG, " Material Document: Item Data
MARA,
MARD,
S031,
EKKO,
EKPO,
LIKP,
MAKT,
J_1IWRKCUS,
T001W,
WB2_V_MKPF_MSEG2,
MMIM_REP_PRINT,
YW2_STKMOVEMENTS,
YPLNT,
MARDH.
Internal Tables *
DATA: I_WERKS LIKE J_1IWRKCUS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_YPLNT OCCURS 0,
PPLNT LIKE YPLNT-PPLNT,
WPLNT LIKE YPLNT-WPLNT,
END OF I_YPLNT.
DATA: BEGIN OF I_MKPF OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
BUDAT LIKE MKPF-BUDAT,
VGART LIKE MKPF-VGART,
BWART LIKE MSEG-BWART,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
KUNNR LIKE MSEG-KUNNR,
ZEILE LIKE MSEG-ZEILE,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
MATNR1 LIKE MSEG-MATNR,
END OF I_MKPF.
DATA: BEGIN OF I_MARDH OCCURS 0,
WERKS LIKE MARDH-WERKS,
MEINS LIKE MARA-MEINS,
MATNR LIKE MARDH-MATNR,
LGORT LIKE MARDH-LGORT,
LABST LIKE MARDH-LABST,
LFGJA LIKE MARDH-LFGJA, "Added -MB
LFMON LIKE MARDH-LFMON, "Added -MB
PERIO(6),
INSME LIKE MARDH-LABST,
EINME LIKE MARDH-LABST,
SPEME LIKE MARDH-LABST,
RETME LIKE MARDH-LABST,
O_STK LIKE MARDH-LABST, " Opening Stock
C_STK LIKE MARDH-LABST, " Closing Stock
END OF I_MARDH.
DATA: BEGIN OF I_MARD OCCURS 0,
WERKS LIKE MARD-WERKS,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
INSME LIKE MARD-LABST,
MEINS LIKE MARA-MEINS,
EINME LIKE MARD-LABST,
SPEME LIKE MARD-LABST,
RETME LIKE MARD-LABST,
END OF I_MARD.
DATA: I_MARD1 LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: I_MARDH1 LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_MKPF1 OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
END OF I_MKPF1.
DATA: BEGIN OF I_MKPF2 OCCURS 0,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
END OF I_MKPF2.
DATA: BEGIN OF I_FINAL5 OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
LGORT LIKE MSEG-LGORT, " Storage Location
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TLOSS LIKE MARDH-LABST, " Total Loss
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
C_STK LIKE MARDH-LABST, " Closing Stock
TRFSTK LIKE MARDH-LABST, "Transfer stock
MENGE LIKE MSEG-MENGE,
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL5.
DATA: BEGIN OF I_FINAL OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL.
DATA: I_FINAL1 LIKE I_FINAL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_FINAL_TEMP OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
MTART LIKE MARA-MTART, " Material Type
MAKTX LIKE MAKT-MAKTX, " Description
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL_TEMP.
For Materials
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MEINS LIKE MARA-MEINS,
LABST TYPE MARD-LABST,
MAKTX LIKE MAKT-MAKTX,
END OF I_MARA.
DATA: BEGIN OF I_STKMVMNTS OCCURS 0,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
VZBEW LIKE YW2_STKMOVEMENTS-VZBEW,
END OF I_STKMVMNTS.
DATA: BEGIN OF I_FINALT OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
MONTH(8) ,
END OF I_FINALT.
DATA: IMKPFT LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT1 LIKE I_MKPF1 OCCURS 0 WITH HEADER LINE.
DATA: IMARDT LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: IMARDHT LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: T_FINAL LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT2 LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
FCAT is used for the field catalog
DATA: FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
for excluding the ICONs from the application toolbar
FEXC TYPE TABLE OF SLIS_EXTAB WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO is used for Grid Layout
FS_LAYO TYPE SLIS_LAYOUT_ALV,
FEVENTS to handle the events TOP OF PAGE & USER_COMMAND
FEVENTS TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER is used for List header
FHEADER TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
sort is used for sorting
FSORT TYPE TABLE OF SLIS_SORTINFO_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FCAT1 TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO1 TYPE SLIS_LAYOUT_ALV,
GT_LIST_TOP_OF_PAGE1 TYPE SLIS_T_LISTHEADER,
FEVENTS1 TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER1 TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT
KEY WITH HEADER LINE INITIAL SIZE 0,
G_STATU_071 TYPE SLIS_FORMNAME VALUE 'Z_PFSTATUS',
ALV_VARIANT1 LIKE DISVARIANT.
Variable Declaration *
TYPES: TRFF_TYPE_DEC_6_5(6) TYPE P DECIMALS 5.
DATA: FYEAR(4),
MON(2),
FYEAR1(4),
MON1(2),
OBAL LIKE MARD-LABST,
CBAL LIKE MARD-LABST,
INDEX TYPE I,
COUNT,
COUNT1 TYPE I,
O_STK TYPE P DECIMALS 3,
C_STK TYPE P DECIMALS 3,
V_MJAHR LIKE MKPF-MJAHR,
MONTHS TYPE TRFF_TYPE_DEC_6_5,
MONTH TYPE I.
Global variables for handling ALV functionality
DATA: ALV_KEYINFO TYPE SLIS_KEYINFO_ALV,
ALV_VARIANT LIKE DISVARIANT,
ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
ALV_REPID LIKE SY-REPID,
ALV_PRINT TYPE SLIS_PRINT_ALV,
ALV_DETAIL_FUNC(30),
ALV_DEFAULT_VARIANT LIKE DISVARIANT-VARIANT,
ALV_COLOURIZE_FIELDS LIKE MMIM_REP_PRINT-COLOR.
RANGES: R_BUDAT FOR MKPF-BUDAT.
*Added by Prabhu for year on 26.4.05.
DATA: IDATE LIKE R_BUDAT OCCURS 0 WITH HEADER LINE.
Selection Screen Elements *
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY NO INTERVALS.
PARAMETER: P_SPMON LIKE S031-SPMON NO-DISPLAY .
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
S_LGORT FOR MSEG-LGORT NO-EXTENSION NO INTERVALS,
S_MBLNR FOR MKPF-MBLNR,
S_BUDAT FOR MKPF-BUDAT OBLIGATORY .
SELECTION-SCREEN END OF BLOCK BLK.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
PARAMETER : MTART LIKE MARA-MTART DEFAULT 'FERT' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK BLK3.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN END OF BLOCK BLK2.
ADDED BY PRABHU FOR DAY-WISE REPORT.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-007.
PARAMETERS: D1 RADIOBUTTON GROUP P1 DEFAULT 'X',
M1 RADIOBUTTON GROUP P1,
Y1 RADIOBUTTON GROUP P1.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
PARAMETERS: ALV_DEF LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK B2.
DATA: S_BUDAT1 LIKE S_BUDAT OCCURS 0 WITH HEADER LINE."prabhu
Initialization *
INITIALIZATION.
PERFORM ALV_INIT.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ALV_DEF.
PERFORM ALV_F4.
At Selection Screen
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
PERFORM monat_f4.
At Selection Screen *
AT SELECTION-SCREEN.
checking for the layout
PERFORM ALV_CHECK.
authorisation check for the Plant
PERFORM auth_check.
Validation for the Plant
PERFORM VALIDITY_CHECK.
IF MTART NE 'FERT'.
MESSAGE E041 WITH 'Material Type must be FERT Only...'.
ENDIF.
IF D1 = 'X'." On 26.4.05.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ELSE.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ENDIF.
LOOP AT S_BUDAT.
IF S_BUDAT-HIGH IS INITIAL.
S_BUDAT-HIGH = S_BUDAT-LOW.
MODIFY S_BUDAT.
ENDIF.
ENDLOOP.
IDATE-LOW = S_BUDAT-LOW.
IDATE-HIGH = S_BUDAT-HIGH.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = IDATE-LOW
I_DATE_TO = IDATE-HIGH
IMPORTING
E_DAYS =
E_MONTHS = MONTH
E_YEARS =
DATA: I(3) TYPE C.
I = S_BUDAT-LOW+4(2).
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*added by Prabhu for Only for Oneday.on 18.5.5
IF MONTH EQ '0'.
MONTH = MONTH + 1.
ENDIF.
*added by Prabhu for Only for Oneday.on 18.5.5
DO MONTH TIMES.
R_BUDAT-LOW = S_BUDAT-LOW.
APPEND R_BUDAT.
ENDDO.
I = 0.
LOOP AT R_BUDAT.
R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2) + I.
I = I + 1.
R_BUDAT-LOW+6(2) = '01'.
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_BUDAT-LOW
IMPORTING
LAST_DAY_OF_MONTH = R_BUDAT-HIGH
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
IF R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2).
R_BUDAT-LOW = S_BUDAT-LOW.
MODIFY R_BUDAT.
ENDIF.
IF R_BUDAT-HIGH4(2) = S_BUDAT-HIGH4(2).
R_BUDAT-HIGH = S_BUDAT-HIGH.
MODIFY R_BUDAT.
ENDIF.
For Summary on 26.4.05.
IF Y1 = 'X'.
CLEAR R_BUDAT.
REFRESH R_BUDAT.
R_BUDAT-LOW = S_BUDAT-LOW.
R_BUDAT-HIGH = S_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR R_BUDAT.
ENDIF.
ENDLOOP.
At Selection Screen *
AT SELECTION-SCREEN OUTPUT.
Start of Selection *
START-OF-SELECTION.
V_MJAHR = P_SPMON+0(4).
Get plant distinction warehouse/production
PERFORM GET_PLANT_DISTINCTION.
Collect the data from various tables
PERFORM GETDATA_FG_STOCK.
here the number of rows in the output table is found
PERFORM OUTPUT_TABLE_CHECK.
here the top of the page code is written, that is to be displayed
in the output
PERFORM Z_TOP_OF_PAGE.
here ALV layout properties are set
PERFORM Z_LAYOUT_SETTINGS.
ALV EVENTS for TOP OF PAGE and for USER COMMAND
PERFORM Z_ALV_EVENTS.
The field catalog is defined for the Primary List is defined in
the subroutine CREATE_FIELD_CATALOG include program ZPRRDOCR_FCAT
PERFORM Z_CREATE_FIELD_CATALOG.
This is for displaying the output
PERFORM Z_REUSE_ALV_GRID_DISPLAY.
*& Form getdata_fg_stock
Getting data from standard tables
FORM GETDATA_FG_STOCK.
For getting the Start date & end date of the month
PERFORM get_month_dates.
Getting the Opening Stock from MARDH table
IF MON EQ '01'.
MON1 = MON.
FYEAR1 = FYEAR.
MON = '12'.
FYEAR = FYEAR - 1.
ELSE.
MON1 = MON.
FYEAR1 = FYEAR.
MON = MON - 1.
FYEAR = FYEAR.
ENDIF.
PERFORM GET_RECORDS_FROM_DB.
*added for Month Summary on 26.4.05.
LOOP AT R_BUDAT.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
*for Month
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
*for summary.
IF Y1 = 'X'.
LOOP AT S_BUDAT.
S_BUDAT1-SIGN = 'I'.
S_BUDAT1-OPTION = 'NB'.
S_BUDAT1-LOW = S_BUDAT-LOW.
S_BUDAT1-HIGH = S_BUDAT-HIGH.
APPEND S_BUDAT1.
CLEAR S_BUDAT1.
ENDLOOP.
ENDIF.
IMKPFT[] = I_MKPF[].
IMKPFT2[] = I_MKPF[].
IMARDT[] = I_MARD[].
IMARDHT[] = I_MARDH[].
PERFORM MONTH_WISE.
PERFORM PROCESS_MOVEMENTS.
PERFORM CALCULATE_OPENING_STOCK.
PERFORM UPDATE_NON_TRANSACTION_ITMS.
PERFORM DELETE_EMPTY_RECORDS.
CLEAR: IMARDHT,IMARDT,IMKPFT1,IMKPFT,I_FINAL,I_FINAL5.
REFRESH: IMARDHT,IMARDT,IMKPFT1,I_FINAL,I_FINAL5,IMKPFT.
ENDLOOP.
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*end of changes for month.
ENDFORM. " getdata_fg_stock
FORM MONAT_F4 *
F4-Hilfe für Monat *
FORM MONAT_F4.
DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1.
INCLUDE STRUCTURE DYNPREAD.
DATA: END OF MF_DYNPFIELDS.
DATA: MF_RETURNCODE LIKE SY-SUBRC,
MF_MONAT LIKE ISELLIST-MONTH,
MF_HLP_REPID LIKE SY-REPID.
FIELD-SYMBOLS: .
Wert von Dynpro lesen
GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.
APPEND MF_DYNPFIELDS.
MF_HLP_REPID = SY-REPID.
DO 2 TIMES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07.
IF SY-SUBRC = 3.
Aktuelles Dynpro ist Wertemengenbild
MF_HLP_REPID = 'SAPLALDB'.
ELSE.
READ TABLE MF_DYNPFIELDS INDEX 1.
Unterstriche durch Blanks ersetzen
TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.
EXIT.
ENDIF.
ENDDO.
IF SY-SUBRC = 0.
Konvertierung ins interne Format
CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
EXPORTING
INPUT = MF_DYNPFIELDS-FIELDVALUE
IMPORTING
OUTPUT = MF_MONAT
EXCEPTIONS
ERROR_MESSAGE = 1.
IF MF_MONAT IS INITIAL.
Monat ist initial => Vorschlagswert aus akt. Datum ableiten
MF_MONAT = SY-DATLO(6).
ENDIF.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = MF_MONAT
IMPORTING
SELECTED_MONTH = MF_MONAT
RETURN_CODE = MF_RETURNCODE
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 01
HOLIDAY_CALENDAR_NOT_FOUND = 02
MONTH_NOT_FOUND = 03.
IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.
ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804
<MF_FELD> = MF_MONAT.
CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
EXPORTING
INPUT = MF_MONAT
IMPORTING
OUTPUT = MF_DYNPFIELDS-FIELDVALUE.
COLLECT MF_DYNPFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07. "<<== note 148804
ENDIF.
ENDIF.
ENDFORM. "MONAT_F4
*& Form get_month_dates
Calculating the Month Start & End Date
FORM GET_MONTH_DATES.
IF M1 = 'X'.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR S_BUDAT.
REFRESH S_BUDAT.
S_BUDAT-SIGN = 'I'.
S_BUDAT-OPTION = 'BT'.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
APPEND S_BUDAT.
ELSE.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
ENDIF.
ENDFORM. " get_month_dates
*& Form output_table_Check
checking for records for output
FORM OUTPUT_TABLE_CHECK .
DESCRIBE TABLE I_FINALT LINES INDEX.
IF INDEX EQ 0.
MESSAGE I041 WITH TEXT-005.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. "OUTPUT_TABLE_CHECK
*& Form Z_TOP_OF_PAGE
for setting the details in the top of page *
has no formal paramters *
FORM Z_TOP_OF_PAGE.
DATA: V_MON(2),
V_YR(40),
V_FIN(18),
V_FIN1(48),
LOW(10),
HIGH(10).
V_MON = P_SPMON+4(2).
V_YR = P_SPMON+0(4).
FHEADER-TYP = 'H'.
FHEADER-INFO = 'Stock Register Report (FG Stock)'.
APPEND FHEADER.
CLEAR FHEADER.
*if m1 = 'X'.
CONCATENATE 'Month = ' v_mon '.' v_yr INTO v_fin.
fheader-typ = 'H'.
fheader-info = v_fin.
APPEND fheader.
CLEAR fheader.
*endif."prabhu on 18.5.5
IF D1 = 'X'.
CLEAR S_BUDAT.
LOOP AT S_BUDAT.
CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/'
S_BUDAT-LOW+0(4) INTO LOW.
CONCATENATE S_BUDAT-HIGH6(2) '/' S_BUDAT-HIGH4(2) '/'
S_BUDAT-HIGH+0(4) INTO HIGH.
CONCATENATE 'Date = ' LOW ' - ' HIGH INTO V_FIN1.
FHEADER-TYP = 'H'.
FHEADER-INFO = V_FIN1.
APPEND FHEADER.
CLEAR FHEADER.
ENDLOOP.
ENDIF.
ENDFORM. " Z_TOP_OF_PAGE
*& Form Z_LAYOUT_SETTINGS
this is done for setting the properties for the layout of the *
grid *
has no formal paramters *
FORM Z_LAYOUT_SETTINGS.
FS_LAYO-ZEBRA = 'X'. " Output in Zebra pattern
FS_LAYO-DETAIL_POPUP = 'X'. " A popup window appears to give
FS_LAYO-DETAIL_TITLEBAR = TEXT-022.
FS_LAYO-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " Z_LAYOUT_SETTINGS
*& Form Z_ALV_EVENTS
This is used for handling the events TOP OF PAGE and the USER *
COMMAND event *
has no formal paramters *
FORM Z_ALV_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = FEVENTS[].
READ TABLE FEVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_TOPOFPAGE'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
READ TABLE FEVENTS WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_USER_COMMAND'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
ENDFORM. "Z_ALV_EVENTS
*& Form Z_CREATE_FIELD_CATALOG
here the field catalog is created for the primary list *
no formal parameters *
FORM Z_CREATE_FIELD_CATALOG.
for the Plant
FCAT-FIELDNAME = 'WERKS'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000005'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Plant'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Type
FCAT-FIELDNAME = 'MTART'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000006'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MatTyp'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material No.
FCAT-FIELDNAME = 'MATNR'.
FCAT-KEY = 'X'.
fcat-hotspot = 'X'.
FCAT-OUTPUTLEN = '000018'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Material'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Description
FCAT-FIELDNAME = 'MAKTX'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '000040'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Description'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Unit of Measure
FCAT-FIELDNAME = 'MEINS'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '03'.
FCAT-JUST = 'C'.
FCAT-SELTEXT_M = 'UOM'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'UNIT'.
APPEND FCAT.
CLEAR FCAT.
for the Plant
FCAT-FIELDNAME = 'MONTH'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '08'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MONTH'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Opening Stock
FCAT-FIELDNAME = 'C_STK'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Opening Stock'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
fcat-do_sum = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Total Receipts
FCAT-FIELDNAME = 'TRECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Receipts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Production
FCAT-FIELDNAME = 'PRODU'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Production'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Other Plant Receipts
FCAT-FIELDNAME = 'RECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Othr Plnt Recpts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Sales Return
FCAT-FIELDNAME = 'SAL_RET'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Sales Return'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Total Dispatches
FCAT-FIELDNAME = 'TDISP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Dispatches'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT. -
Regaring opening stock and closing stock in MM
hi guys,
can any body plzz tell me what exactly do u mean by
1) opening stock (OS)
2) closing stock (CS)
3) credit indicator
4) debit indicator
in MM, i actually checked bseg table for documentation of these fields but could not understand can any one plzz help me.
thanks very much
pavanHello Pavan
What exactly do you wish to know the definitions or calculation.
Opening stock : It is the initial stock available for a particular material at a particular plant/sloc (when the sku was created).
Closing stock : It is the current stock available, basically Opening stock + receipts - issue.
Credit/Debit indicator : Basically, they indicate whether the stock was received at the location or issued from the location.
Regards
Anurag -
MB5B -- Opening stock and closing stock
Hi experts ,
What is mean for opening stock adn closing stock ?
In case of I input the same data of selection dHow they are calculated in MB5B ?
For some material , the closing stock is 0, but why the closing value is not 0 ?
BR , shubin
Edited by: Shubin Tan on Nov 20, 2009 4:46 AMOpening stock:-stock at the beginning of the day
Closing Stock:- Stock at the end of GI and GRs
Reports like MB5B (Stock on posting date) can offer negative results
when executed for dates previous to the goods receipt, but this is only
a reporting issue: if the program is correctly executed for the complete
period (month/year), it should never show negative values.
The reason for the system behaviour you describe is that at the time of
a goods issue, the system only validates whether sufficient stock is
available in the posting period and not on that specific posting date.
So as described, if you specify a previous date, the stock for that
date may be negative, but actually your stock value is always correct.
If you are posting the goods issue in the previous period, the system
will issue an error message. But if the postings occur in the same
period with different dates, the system will not issue any error and
the stocks will be shown in negative.
Regards
V V -
Opening stock will be the closing stock of previous date
Hi All,
Good day. I am developing an ALV report that will show opening stock(LABST) as well as closing stock(Calculated) for a range of date and materials. Problem here is that from MARD table I am getting only the last opening stock, because it has no common date field with MSEG table. So, I have to calculate the opening stock as the closing stock of previous date. How can I calculate this? Is there any FM to get the opening stock ?
Date Material Opening St Closing St
27.03.2009 2100002 91.000 191.00
28.03.2009 2100002 191.000 123.00
29.03.2009 2100002 123.000 103.00
With regards,
Tripod.
Edited by: Tripod on Aug 23, 2011 12:13 PMTry not only to use MARD and MKPF/MSEG but also MARDH which contains closing stock of period preceding periods where movements happened. (ie. there is a record for May if a movement happened in June, and none for June if there was no movement in July, and no record exists for August as this is current period) - First look for MARD, MARDH records; and then only read MKPF/MSEG from last MARDH record found. (created back to 4.5A - [Material Master (Industry/Retail): Enhancements to Period Closing|http://help.sap.com/saphelp_45b/helpdata/en/35/b0e7ef87a62488e10000009b38f9b7/content.htm])
Regards,
Raymond -
Stock calculation report in mm module
Hi all,
I have developed report for stock calculation in mm module. my opening stock and closing stock is not matching with that of MB5B.can anyone provide the guidance into this as I have worked on mm reports.
Regards,
Harshadadeclarations:
* Structure type Declarations
TYPES : BEGIN OF STYPE_MSEG_LEAN,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
BLART LIKE MKPF-BLART,
BUDAT LIKE MKPF-BUDAT,
CPUDT LIKE MKPF-CPUDT,
CPUTM LIKE MKPF-CPUTM,
USNAM LIKE MKPF-USNAM,
XABLN LIKE MKPF-XABLN,
LBBSA LIKE T156M-LBBSA,
BWAGR LIKE T156S-BWAGR,
BUKRS LIKE T001-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
WAERS LIKE MSEG-WAERS,
ZEILE LIKE MSEG-ZEILE,
BWART LIKE MSEG-BWART,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
CHARG LIKE MSEG-CHARG,
BWTAR LIKE MSEG-BWTAR,
KZVBR LIKE MSEG-KZVBR,
KZBEW LIKE MSEG-KZBEW,
SOBKZ LIKE MSEG-SOBKZ,
KZZUG LIKE MSEG-KZZUG,
BUSTM LIKE MSEG-BUSTM,
BUSTW LIKE MSEG-BUSTW,
MENGU LIKE MSEG-MENGU,
WERTU LIKE MSEG-WERTU,
SHKZG LIKE MSEG-SHKZG,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
DMBTR LIKE MSEG-DMBTR,
DMBUM LIKE MSEG-DMBUM,
XAUTO LIKE MSEG-XAUTO,
KZBWS LIKE MSEG-KZBWS,
retail(01) type c,
oiglcalc(01) type c,
oiglsku(07) type p decimals 3,
insmk like mseg-insmk,
* the following fields are used for the selection of
* the reversal movements
SMBLN LIKE MSEG-SMBLN, " No. doc
SJAHR LIKE MSEG-SJAHR, " Year
SMBLP LIKE MSEG-SMBLP. " Item in doc
TYPES : END OF STYPE_MSEG_LEAN.
TYPES: STAB_MSEG_LEAN TYPE STANDARD TABLE OF STYPE_MSEG_LEAN
WITH KEY MBLNR MJAHR.
* Data Declarations
DATA : G_S_MSEG_LEAN TYPE STYPE_MSEG_LEAN,
G_S_MSEG_UPDATE TYPE STYPE_MSEG_LEAN,
G_T_MSEG_LEAN TYPE STAB_MSEG_LEAN,
AKTDAT LIKE SY-DATLO,
INDEX_2 LIKE SY-TABIX.
DATA: BEGIN OF IMSWEG OCCURS 1000,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
MATNR LIKE MSEG-MATNR,
CHARG LIKE MSEG-CHARG,
BWTAR LIKE MSEG-BWTAR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
SOBKZ LIKE MSEG-SOBKZ,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
XAUTO LIKE MSEG-XAUTO,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
DMBTR LIKE MSEG-DMBTR,
DMBUM LIKE MSEG-DMBUM,
BUSTM LIKE MSEG-BUSTM,
BUSTW LIKE MSEG-BUSTW,
oiglcalc(01) type c,
oiglsku(07) type p decimals 3,
insmk like mseg-insmk,
END OF IMSWEG.
DATA: BEGIN OF SUM_MAT OCCURS 100,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
SHKZG LIKE MSEG-SHKZG,
MENGE(09) TYPE P DECIMALS 3,
END OF SUM_MAT.
Edited by: Kartik Tarla on Aug 5, 2010 7:06 PM -
Stock Ledger Report in Day Wise not giving correct values for Opening Stock
Dear Experts,
I m working on Sock ledger report to give the day wise data.
since yesterdays closing Stock will become opening stock of today,
To get Opening Stock,
I have restricted the stock key figure with 2 variables on calday
(DATE FROM var with <=(Lessthan or equal to) and offset -1
DATE TO var with <=(Lessthan or equal to) and offset -1)
To get Closing Stock,
I have restricted the Stock key figure with 2 variables on calday
(DATE FROM var with <=(Lessthan or equal to)
DATE TO var with <=(Lessthan or equal to) )
But in the output Opening stock values are not coming correctly and for given range of dates,
for last date, opening stock is showing as Zero.
Could you please tell me how can I achieve the correct values for opening stock.
Thanks in advance.Hi Arjun,
Seems like you are making it more complicated. What is your selection screen criteria?
Ideally you should only use the offset.
You will have say Calday in rows and stock in Column
____________Opening Stock_____________Closing Stock
01/06/2009___(Closing stock of 31/05/2009)_(Stock of 01/06/2009)
02/06/2009___(Closing stock of 01/06/2009)_(Stock of 02/06/2009)
03/06/2009___(Closing stock of 02/06/2009)_(Stock of 03/06/2009)
So, from above scenario, create one RKFs and include Calday in it. Create a replacement path variable on calday and apply the offset as -1.
So, your Opening Stock will be calculated by closign stock of previous day.
- Danny -
Hi,
I am writing FS for the following fields
In selection screen i am selecting
Material
Posting date
Plant
Output
Opening stock stock
GR
Issue
Balance
Closing Stock
My problem is from which table to fetch opening stock qty which belongs to 3months back
For example i am running this report from Jan09 to March 09 so my query i want opening stock for the month of Jan09 and subsequently reduction in stock after each issue.so from which table i can get this information.
Need your expertise help
Regards
VivekHi Vivek,
To Calculate Opening Stock & Closing stock there are different procedures.
It just depends of\n the client requirements & usage of the material.
For example, we have different types of stocks, like, Through Pipeline, Special, Unristricted, quality, safety,
and many types of stocks.... so all these types are indicated in MSEG tabe in SOBTZ field,...
Now Comimg to your Query, You need to calculate OPENING & CLOSING STOCK.
We have a similiar standard report in MB5B Tcode..
to get the same results in your report do like this...
For valuated stock go to the MARDH, MBEWH, MCHBH tables But I Prefer MBEWH.
here in MBEWH give the month & year and you get the result in LBKUM field...
For Special stock, You need to go to another table like MKOLH,,(I forgot still 2 more) and
give the month & year inputs and you will get the result in SLABS field.
and remaining MB5B refers to its deetails lists with different Movement types,
whcih you can get clearly from MSEG Table...
Hope you can write the select Queries accordingly.
If you want to find the Stock for a particluar date, It is not available in any table as I know,
Rather you need to do calculations like this.
1. Select the stock (Menge) till date from MSEG and add all with different movement types,
Its a logic need to ask to your functional consultant,
like 101 added to stock, 601 sales, 102 rejeted, 602 added back to stock,... transfers, 261,,, like this.
But take a little time, get all these by using MKPF & MSEG tables... thats it.
Or----
2.Tables are MSEG , MKPF ... use Debit / Credit indicator ( Do not go woth any static Movement types ) and u have to consider all stock related table
MBEW , EBEW etc..., to get the stcok on particular date .
Please refer to Std. Tcode FBL5N for reference.
Thanks & regards,
Dileep .C -
Opening stock for meterial monthwise
hi experts ...
I m developing a report , in which i need any of opening stock or closing stock.
plz tell me from which table i can get any of this two fields. if there is any calculation to done ,plz give me the formula for this stocks.
thank you.Hi Ankita
check MSEG table
i could not post full code please understand this logic
IF IT_FINAL[] IS NOT INITIAL.
IF THE USER DOEN NOT SELECT SPECIAL STOCK
IF P_CHK IS INITIAL.
SELECT MBLNR BWART ZEILE MATNR WERKS LGORT SHKZG ERFMG ERFME
FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_QUAN FOR
ALL ENTRIES IN IT_FINAL WHERE MATNR = IT_FINAL-MATNR AND
WERKS IN S_WERKS
AND LGORT IN S_LGORT
AND SOBKZ NOT IN ('E','K','M','O','P','Q','V','W','Y').
ELSE.
SELECT MBLNR BWART ZEILE MATNR WERKS LGORT SHKZG ERFMG ERFME
FROM MSEG INTO CORRESPONDING FIELDS OF TABLE
IT_QUAN FOR
ALL ENTRIES IN IT_FINAL WHERE MATNR = IT_FINAL-MATNR AND
WERKS IN S_WERKS
AND LGORT IN S_LGORT.
ENDIF.
ENDIF.
IF IT_QUAN[] IS NOT INITIAL.
GETTING THE MATERIAL DOCUMENTS FOR SPECIFIED PERIOD
SELECT MBLNR BUDAT FROM MKPF
INTO CORRESPONDING FIELDS OF TABLE IT_BUDAT
FOR ALL ENTRIES IN IT_QUAN
WHERE ( BUDAT GE DATE1 AND BUDAT LT DATE2 )
AND MBLNR = IT_QUAN-MBLNR.
SELECT MBLNR BUDAT FROM MKPF
INTO CORRESPONDING FIELDS OF TABLE IT_BUDAT1
FOR ALL ENTRIES IN IT_QUAN
WHERE MBLNR = IT_QUAN-MBLNR
AND BUDAT LT DATE1.
ENDIF.
CLEAR INDEX.
LOOP AT IT_FINAL.
INDEX = SY-TABIX.
LOOP AT IT_QUAN WHERE MATNR = IT_FINAL-MATNR
AND WERKS = IT_FINAL-WERKS
AND LGORT = IT_FINAL-LGORT.
IF SY-SUBRC = 0.
IF IT IS IN CALCULATE QUANTITY
IF IT_QUAN-SHKZG = 'S'.
check the unit if it is gram then devide by 1000.
IF IT_QUAN-ERFME = 'G'.
IT_QUAN-ERFMG = IT_QUAN-ERFMG / 1000.
ENDIF.
IN_QTY = IN_QTY + IT_QUAN-ERFMG.
ENDIF.
IF IT IS OUT CALCULATE QUANTITY
IF IT_QUAN-SHKZG = 'H'.
IF IT_QUAN-ERFME = 'G'.
IT_QUAN-ERFMG = IT_QUAN-ERFMG / 1000.
ENDIF.
OUT_QTY = OUT_QTY + IT_QUAN-ERFMG.
ENDIF.
ENDIF.
ENDLOOP.
IT_FINAL-IN = IN_QTY.
IT_FINAL-OUT = OUT_QTY.
for closing stock
LOOP AT IT_FINAL.
IT_FINAL-CLOS_QUAN = IT_FINAL-OPEN_QUAN +
IT_FINAL-IN - IT_FINAL-OUT.
MODIFY IT_FINAL INDEX SY-TABIX.
CLEAR IT_FINAL.
ENDLOOP.
reward points to all helpful answers
kiran.M -
Block stock calculation from mseg table for any given date.
I am calculating stock from mseg table for any given date. Not just month end stock or current stock. It could be back date also. It is tallying also with MB5B stock report of that date. Now I have to bifurcate that stock into unrestricted stock, quality stock and block stock.
I have checked INSMK and ZUSTD field in mseg table, but could not concluded. Should I check movement type wise? Block/ Quality stock could be transferred into unrestricted stock also. That also I have to take care.
Can anyone clearly explain how the stock type posting takes place in mseg table when goods receipt as block / quality stock and when the same goods transferred in unrestricted stock, what are the reference indication.DATA : LIST_TAB TYPE TABLE OF ABAPLIST.
DATA: BEGIN OF VLIST OCCURS 0,
FIELD1(5) TYPE C,
FIELD2(19) TYPE C,
FIELD3(16) TYPE C,
FIELD4(17) TYPE C,
FIELD5(25) TYPE C,
FIELD6(24) TYPE C,
FIELD7(25) TYPE C,
FIELD8(25) TYPE C,
END OF VLIST.
TYPES : BEGIN OF ITAB,
MATNR(18) TYPE C,
WERKS(5) TYPE C,
END_MENGE(20) TYPE C,
END OF ITAB.
DATA : ITAB TYPE STANDARD TABLE OF ITAB WITH HEADER LINE,
WA_TAB TYPE ITAB.
----submit command to run mb5b in the background and -
----push the data into an internal table -
" Calling MB5B for displaying the Closing Stock
SUBMIT RM07MLBD USING SELECTION-SCREEN '1000'
WITH DATUM BETWEEN S_DATE-LOW AND S_DATE-HIGH
WITH MATNR IN S_MATNR WITH WERKS IN S_WERKS
WITH BWART-LOW = '601' EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LIST_TAB
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = VLIST
LISTOBJECT = LIST_TAB
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
LOOP AT VLIST WHERE FIELD1 CS '|'.
CHECK SY-TABIX GE 4.
MOVE : VLIST-FIELD1+1(4) TO ITAB-WERKS,
VLIST-FIELD2+1(18) TO ITAB-MATNR,
VLIST-FIELD8 TO ITAB-END_MENGE.
APPEND ITAB.
ENDLOOP.
This is the program to call MB5B and the standard program and use the following settings for the closing stock opening stock and block stock -
Report for shedule vs supply and report for opening stock at back date.
Dear All Guru,
please can anybody reply me is there any standard report is available for
1) Report for shedule vs supply
2) and report for opening stock at back date.(ex- opening stock at last month 16th july or two months back on 10th may
pl suggest if any standard report is available or how we can data for this
Regards,
VimleshHi,
To see the opening stock at a particular date use T.Code: MB5B,
To see the scheduled quantity & delivered quantity use table EKET with the filed names MENGE & WEMNG.
Regards,
Prabu
Maybe you are looking for
-
Hi, How to display only the TOP 10 rows in a cross tab based on the Total field. I am using BW as my source. Thanks and Regards, Subbu S.
-
How do I clear my searching history?
I tried resetting Safari, clearing my cache, and clearing the history, but after I do all this it still tries to auto-fill when I type something in the search field in Yahoo. How do I delete everything I've typed in a search field?
-
I'm upgrading my 10.2.0.4 to 11.2.0.1 on RHEL5.4. I start up the 11.2 dbua, and select the database to upgrade, then dbua pops up a box that says: "The database is using ASM as storage. Before you upgrade the database, you need to upgrade ASM using A
-
Dear Experts, I was wondering if anyone could kindly help me. I have an Oracle Database installed on my pc and with installation Apache was also installed. The problem I have is I cannot access the web server. I am using Windows XP. From windows if I
-
How do I delete tv shows from my ipod?
I thought I was doing the right thing by after importing tv shows into itunes and finding that they showed up as movies by filling out the episode info etc. and changing them to tv shows. Well now I can't even find them in itunes. Where are they and