Closing stock by referring J_1IRG23D table
Dear All,
I have 3 different production plant (P-1, P-2, P-3)
These 3 plants produce same material and send to Depot plant.
So once production plant send material to depot plant then RG1 register get upate at prodution plant and once depot plant receive that material then RG23D register update. Then depot sales those material with reference with production plant invoice.
So my requirement is i need to check in each period wise what is the closing stock at each depot plant and then i need to trace for each material that from which production plant it is received for that period.
So how i can built a logic by referring J_1IRG23D table?
Dear Maruthi,
Requirement is like this
I have a finished material say 'X' and material X i use 10KG of Copper in my BOM.(copper contain for different MFG plant is different)
But X is manufactured by plant A,B and C.
So i need to develop a report for closing stock of each depot plant. If i found X is available in my depot plant 'P-1'is 10KM then i have to check from which MFG plant it has come then again i have to go to that MFG plant and drill down the BOM and will calculate copper contained.
Similar Messages
-
MB5B Report table for Open and Closing stock on date wise
Hi Frds,
I am trying get values of Open and Closing stock on date wise form the Table MARD and MBEW -Material Valuation but it does not match with MB5B reports,
Could anyone suggest correct table to fetch the values Open and Closing stock on date wise for MB5B reports.
Thanks
Mohan MHi,
Please check the below links...
Query for Opening And Closing Stock
Inventory Opening and Closing Stock
open stock and closing stock
Kuber -
Open order qty,Delivered qty,issued qty, and closing stock---Tables
Gurus,
I need to Prepare a report which will show open order qty,Delivered qty,issued qty, and closing stock.
Please help me with table names where i can find .
Regards
venu gopalHi,
Try EKPO & EKBE tables..
Thx
Raju -
Material opening and closing stock for a given day- Tables or FM
Dear Friends
i have to make a report , related to Material opening and closing stock for a given day , i check the T-Code- MB5B ,
it is not giving correct date . is any functional module is available ? . i checked some table like mbew , mard . it is also not giving correct requirement . Please helpHi
Goto transaction MC.9, Give your Material and,Plant and the date which you need to know the closing stock. Do make sure that in the high and low values you are giving the same date there. I guess no such FM are available for this. You can refer the [Link|https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=15856] for some help.
Regards
Vinodh
Edited by: Vinodh_AN on Dec 15, 2010 9:19 AM
Edited by: Vinodh_AN on Dec 15, 2010 9:25 AM -
Tables/FM for opening/closing stock for material on given posting date
Hi All,
I had requirement of find the opening/closing stock for material on given posting date. The values we can find out using TCode - MB5B.
But I cannt use MB5B to extract data because I need to find detials for thousands of material.
Can you please adivce if their is any FM or tables through which i can find this detial on any given date apart from current date.
Thanks & Regards,Hi,
[https://forums.sdn.sap.com/click.jspa?searchID=19631709&messageID=6593903]
[https://forums.sdn.sap.com/click.jspa?searchID=19631709&messageID=6630975] -
Table name for opening and closing stock
Hi gurus,
i want table name for opening and closing stock . How to calculate this opening and closing stock in report.
Murali.Murali,
Check out in OINM, which maintains all the details of the stock transactions..
Hope it might help you..
Regards
Gattu -
Hi ,
My requirement is to make Z table for closing stock.
As ours is a pharma firm and we have implemented SAP in Aug 2008.
Now for closing stk we are using S033 and MSEG table to get opening stk
SELECT SUM( mzubb ) SUM( magbb ) INTO (w_dr_menge , w_cr_menge)
FROM s033
WHERE sptag < so_fkdat-low
AND werks = werks
AND matnr = matnr.
w_opening_balance = w_dr_menge - w_cr_menge.
and for closing stk = opening stk - sale + receive.
Now the problem is when we want to retrieve data for closing stk for last month ,it is checking all the records since Aug 2008 for opening stk and it is taking too much time to retrieve data.
Can anyone plz suggest any alternative for thsi problem.
I will really appriciate your help.
Regards,
ArchanaHi
done this before. for sure you will experience an performance problem in your current setup. what we did is we create a program that calculates the ending inventory of the month then beginning inventory of the following month we are executing this in every end of the month. In that case when we need to access the previous month the ztable must be use. make sure that your program can do rerun of the ending and beginning of stock because there are chances of previous posting of reversals.
Thanks,
Best regards,
Etrafanob -
Tables / tcodes for closing stock of everyday
Dear Experts,
from which tables (if i get tables name it would be more useful) / transaction can i get the closing stock of everyday?
Kind Regards
SajidSir,
Pl use following tables
Material Stock Balances MARD Material stock
MBEW Material stock with Valuations -
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. -
Reg:Opening and Closing Stock For Plant
Hi All,
i want to calculate the opening stock and closing stock for plant wise for the given Posting Period Date.
Am having the opening balance and closing balance for all months but i need it as month wise.
considering this example,
the date is from 15.01.2010 to 15.03.2010 and for one plant
considering this example,
am having the opening stock from as 15.01.2010 to 15.03.2010 as 10,000 and the closing stock as 15,000.
but i need in month wise like below,
from 15.01.2010 to 31.01.2010 what is the opening stock and closing stock?
from 01.02.2010 to 28.02.2010 what is the opening stock and closing stock?
from 01.03.2010 to 15.03.2010 what is the opening stock and closing stock?
this is purely based on plant wise and not material wise?
could anybody say clearly how can i acheive this scenario?
i have referred MB5b,mc.9 transaction programs but still confused how to go with plant wise for a particular period?
Thanks & Regards,
Suresh
Edited by: suresh suresh on Mar 24, 2010 10:15 AMHi,
Refer to link below:
http://help.sap.com/erp2005_ehp_04/helpdata/EN/c1/3766e7449a11d188fe0000e8322f96/frameset.htm
Regards,
Venkat. -
Closing Stock on Particular Date(MB5B Tcode)
Hi Experts,
I need closing stock as on some particular date. For e.g. closing stock as on 28.02.2014.
In my requirement i have to use that closing stock value for further calculations in a new customized report.I can see closing stock value by using MB5B tcode.
Please suggest some way to get closing stock as on some date so that i can use that in my Report.
Can i directly call MB5B transaction in my Report and get closing stock value?
Thanks & Regards,
PankajHello Pankaj,
In your Customised Report use MKPF and MSEG table
MKPF -----> Material and date range as the input
Then Pass Material document number from MKPF to MSEG table
MSEG -----> based on material document number from mkpf
Create Temporary variable
values comes from the mseg where have credit and debit entries
if debit entry "S" then subtract the values of the Mseg table from the temporary variable1
if credit entry "H" then Add the values of the mseg table to the temporary variable2
finally Add the temporary variable1 and temporary variable 2 and get the total stock. -
Functional Specification For Opening And closing stock On Particular Date
Dear Gurus,
I am creating report for opening and closing stock on particular date in which batch and storage location should also be included. I want to know the tables and fields for the same.I have searched the forum and got report on month basis but I want this report on posting day basis.kindly suggest tables and fields. Thanks in AdvanceDear sir,
There are many other colums that client wants to add which are not present in MB5B transaction.columns which client wants to add are as follows...
Material Number
Material Description
Material Type
Material Group
External material Group
Movement Type
Plant
Storage Location
Customer Number
Customer Name
Vendor Number
Vendor Name
Posting Date Receipt Doc. Number
Issue Doc. Number
Reference Issue Document Number
Opening Stock Quanity
Material Receipt Quantity
Material Issue Quantity
Material Closing Stock Quantity
Value Of Closing Stock
And for this I want tables and logic for the same. kindly provide the solution for the same. -
Closing stock by using opening sock
Hi All,
I got opening stock by using this how can I calculate closing stock,pls help me.
REPORT zhzl_material_analysis_gb LINE-SIZE 1000.
tables:mara,mseg,s034.
TYPE-POOLS: slis.
DATA: budat TYPE budat.
DATA: v_fieldcat TYPE slis_fieldcat_alv,
v_t_fieldcat TYPE slis_t_fieldcat_alv.
*Internal Tables for Opening Stock Calculation
DATA : BEGIN OF t_mbew OCCURS 0,
matnr LIKE mbew-matnr,
bwkey LIKE mbew-bwkey,
lbkum LIKE mbew-lbkum,
salk3 LIKE mbew-salk3,
END OF t_mbew.
DATA: BEGIN OF i_mbew OCCURS 0,
mblnr LIKE mseg-mblnr,
mjahr LIKE mseg-mjahr,
menge LIKE mseg-menge,
meins TYPE meins,
bwart LIKE mseg-bwart,
matnr LIKE mseg-matnr,
*REP werks as bwkey
bwkey LIKE mseg-werks,
shkzg LIKE mseg-shkzg,
dmbtr LIKE mseg-dmbtr,
zeile LIKE mseg-zeile,
smbln LIKE mseg-smbln,
smblp LIKE mseg-smblp,
sjahr LIKE mseg-sjahr,
kunnr LIKE mseg-kunnr,
mblnr1 LIKE mkpf-mblnr,
mjahr1 LIKE mkpf-mjahr,
budat LIKE mkpf-budat,
taxkd LIKE knvi-taxkd,
END OF i_mbew.
DATA: BEGIN OF i_mara OCCURS 0,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
spart LIKE mara-spart,
END OF i_mara.
DATA: i_makt TYPE TABLE OF makt WITH HEADER LINE.
DATA: BEGIN OF i_collect OCCURS 0,
matnr LIKE mara-matnr,
bwkey LIKE mbew-bwkey,
menge LIKE bsim-menge,
dmbtr LIKE bsim-dmbtr,
END OF i_collect.
DATA: BEGIN OF i_op_stock OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
matkl LIKE mara-matkl,
bwkey LIKE mbew-bwkey,
menge LIKE bsim-menge,
dmbtr LIKE bsim-dmbtr,
spart LIKE mara-spart,
END OF i_op_stock.
*The Selection-Screen Construction
SELECTION-SCREEN: BEGIN OF BLOCK sel_block WITH FRAME.
PARAMETER: p_werks LIKE mseg-werks.
*PlantCompany Code
SELECT-OPTIONS : s_date FOR budat,
p_spart for mara-spart,
*Division
p_bukrs for mseg-bukrs .
SELECTION-SCREEN: END OF BLOCK sel_block .
START-OF-SELECTION.
PERFORM opening_stock.
PERFORM alv.
*FORM opening_stock *
*Calculates stock for date value in the low field of the *
*select-options.
FORM opening_stock.
CLEAR t_mbew.
SELECT * FROM mbew INTO CORRESPONDING FIELDS OF TABLE t_mbew
WHERE bwkey = p_werks .
SORT t_mbew BY matnr.
REFRESH i_mbew.
CLEAR i_mbew.
LOOP AT t_mbew.
i_mbew-matnr = t_mbew-matnr.
i_mbew-bwkey = t_mbew-bwkey.
i_mbew-dmbtr = t_mbew-salk3.
i_mbew-menge = t_mbew-lbkum.
APPEND i_mbew.
CLEAR i_mbew.
ENDLOOP.
SELECT
mseg~mblnr
mseg~mjahr
mseg~bwart
mseg~menge
mseg~matnr
mseg~shkzg
mseg~werks AS bwkey
mseg~zeile
mseg~smbln
mseg~smblp
mseg~sjahr
mseg~kunnr
mkpf~mblnr AS mblnr1
mkpf~mjahr AS mjahr1
mkpf~budat
FROM mseg AS mseg INNER JOIN
mkpf AS mkpf ON
msegmblnr = mkpfmblnr
AND
msegmjahr = mkpfmjahr
APPENDING CORRESPONDING FIELDS OF TABLE i_mbew
WHERE mkpf~budat > s_date-low
AND mseg~bukrs in p_bukrs
AND mseg~werks = p_werks
AND mseg~kzvbr = ' '
AND mseg~bustw NE ' '.
SORT i_mbew BY matnr budat mblnr.
SORT i_mara BY matnr.
SORT i_makt BY matnr.
LOOP AT i_mbew.
IF i_mbew-shkzg = 'S'.
i_mbew-dmbtr = i_mbew-dmbtr * ( - 1 ).
i_mbew-menge = i_mbew-menge * ( - 1 ).
ENDIF.
MODIFY i_mbew TRANSPORTING dmbtr menge.
ENDLOOP.
CLEAR i_collect.
LOOP AT i_mbew.
i_collect-matnr = i_mbew-matnr.
i_collect-bwkey = i_mbew-bwkey.
i_collect-dmbtr = i_mbew-dmbtr.
i_collect-menge = i_mbew-menge.
COLLECT i_collect.
ENDLOOP.
CLEAR: i_collect,i_op_stock.
LOOP AT i_collect.
MOVE-CORRESPONDING i_collect TO i_op_stock.
APPEND i_op_stock.
CLEAR i_op_stock.
ENDLOOP.
CHECK NOT i_op_stock[] IS INITIAL.
LOOP AT i_op_stock.
DELETE i_op_stock WHERE menge = 0.
ENDLOOP.
SORT i_op_stock BY matnr.
SELECT * FROM mara INTO CORRESPONDING FIELDS OF TABLE i_mara
FOR ALL ENTRIES IN i_op_stock
WHERE matnr = i_op_stock-matnr
AND spart in p_spart.
SELECT * FROM makt INTO TABLE i_makt
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr
AND spras = 'EN'.
LOOP AT i_op_stock.
CLEAR i_mara.
READ TABLE i_mara WITH KEY matnr = i_op_stock-matnr.
IF sy-subrc = 0.
i_op_stock-matkl = i_mara-matkl.
i_op_stock-spart = i_mara-spart.
MODIFY i_op_stock TRANSPORTING matkl spart.
ELSE.
DELETE i_op_stock.
ENDIF.
ENDLOOP.
LOOP AT i_op_stock.
CLEAR i_makt.
READ TABLE i_makt WITH KEY matnr = i_op_stock-matnr.
IF sy-subrc = 0.
i_op_stock-maktx = i_makt-maktx.
MODIFY i_op_stock TRANSPORTING maktx.
ELSE.
DELETE i_op_stock.
ENDIF.
ENDLOOP.
ENDFORM.
FORM alv.
CLEAR v_fieldcat.
v_fieldcat-col_pos = 1.
v_fieldcat-fieldname = 'MATNR'.
v_fieldcat-seltext_m = 'Material code'.
APPEND v_fieldcat TO v_t_fieldcat.
v_fieldcat-col_pos = 2.
v_fieldcat-fieldname = 'MAKTX'.
v_fieldcat-seltext_m = 'Description'.
APPEND v_fieldcat TO v_t_fieldcat.
v_fieldcat-col_pos = 3.
v_fieldcat-fieldname = 'MATKL'.
v_fieldcat-seltext_m = 'Material Group'.
APPEND v_fieldcat TO v_t_fieldcat.
v_fieldcat-col_pos = 4.
v_fieldcat-fieldname = 'SPART'.
v_fieldcat-seltext_m = 'Division'.
APPEND v_fieldcat TO v_t_fieldcat.
v_fieldcat-col_pos = 5.
v_fieldcat-fieldname = 'BWKEY'.
v_fieldcat-seltext_m = 'Plant'.
APPEND v_fieldcat TO v_t_fieldcat.
v_fieldcat-col_pos = 6.
v_fieldcat-fieldname = 'DMBTR'.
v_fieldcat-seltext_m = 'Amount'.
APPEND v_fieldcat TO v_t_fieldcat.
v_fieldcat-col_pos = 7.
v_fieldcat-fieldname = 'MENGE'.
v_fieldcat-seltext_m = 'Quantity'.
APPEND v_fieldcat TO v_t_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = v_t_fieldcat
TABLES
t_outtab = i_op_stock.
ENDFORM.
Thanks®ds,
Sree.Hi,
Please note that MBEW contains the stock position as of now. MBEWH contains the closing stock of all the previous periods. However if there is no transaction in a particular period you may not find a record in MBEWH for that period.
Please refer to SAP documentation:
[Back To Resultlist]
Material Master (Industry/Retail): Enhancements to Period Closing
Description
In Release 4.5A, the period closing function has been redesigned to eliminate or at least alleviate the following problems:
Long runtime if there are very many stock segments
Locking of all materials while the period closing program is run
Data inconsistencies in stock segments due to incorrect operation of the period closing program by users
The enhancements made to eliminate or alleviate these problems affect the way in which period closing is performed technically and particularly the data design. As a result, the following information is intended primarily for the following persons:
System administrators
Developers (for example, in customer projects)
Other persons in IT departments or systems departments
Runtime
The runtime of the period closing program has been improved substantially since no stock tables (such as MBEW, MARD, or MCHB) are updated any longer for the change in period, unless the change in period is a change in fiscal year. Only the material ledger tables are updated.
If the change in period coincides with the end of a fiscal year, the program also updates the physical inventory indicators and thus those tables relevant to physical inventory management; that is, even in this case, table MBEW in particular is no longer updated.
Locking of materials
The materials are locked by the period closing program only if the material ledger is used.
In the case of a change in fiscal year, no physical inventory transactions can be performed when running the period closing program.
Ease of use
As of Release 4.5A, period closing is performed in inventory management or invoice verification; that is, whenever, for example, a goods movement is made, the period is updated in the relevant stock segments of the material if the material is moved for the first time in this period.
Changes to the interface
There have been no changes to the interface.
Changes in procedure
The implementation of the above enhancements has required the data design to be changed as follows:
Stock tables MBEW, EBEW, QBEW, MARC, MARD, MCHB, MKOL, MSKA, MSSA, MSKU, MSLB, MSPR, and MSSQ now have history tables, for example, MBEWH is the history table for MBEW, and EBEWH the history table for EBEW. For each period, these history tables can contain an entry with the corresponding stock information, and are created for the previous period whenever there is a change in period-relevant information such as unrestricted-use stock. This means that the information for the previous period can no longer be read directly from tables MBEW, EBEW, and so on, but that tables MBEWH, EBEWH, etc. have to be read and interpreted.
The point in time at which the system is upgraded to Release 4.5A is important for interpreting the history tables. If the period has been closed at least once after the upgrade, the stocks for the previous period are contained, for example, in history table MARDH. If this table does not contain a corresponding entry, the previous period stock for the corresponding stock fields is the same as the current stock.
Fields LFMON/LFGJA of the stock tables no longer contain the current period, but one of the following periods, depending on when the upgrade took place:
Period of the last goods movement, invoice verification, price change, or other function that has resulted in period-specific information being updated
Period of the release upgrade if no such function has been performed since the system was upgraded
The current period is still recorded (as prior to Release 4.5A) in table MARV.
Planning
In a future release, it is planned for the data in the material ledger to no longer be updated by the period closing program. This will further increase the speed of the program.
[Back To Resultlist]
Regards
Raju Chitale -
Closing stock of a particular date
how to get plant wise material closing stock on any particular date. say previous months end date. I am calculating that from MSEG table with the help of MSEGINSMK and MSEGSHKZG field. (with date filtaration by joining MBLNR of MKPF table) But stock is showing different with the closing stock showing in MB5B report for that date. I don't know which BWART of MSEG table to be excluded. My email id is [email protected]
Hi,
This is a stock aging report, you can use this for reference.
Logic: Based on current stock and value from MBEW table. The latest receipt dates were taken till the qty tallies off.Rejections and reversals are considered.
The movement types considered are ('101','102','105','106','122','123','131','132','301','302','309','310','501','502','531','532','561','562','701','702').
*& Report ZMM03_TRY *
REPORT ZMM03 LINE-SIZE 226
LINE-COUNT 35(2)
NO STANDARD PAGE HEADING..
TABLES : S032, "Current Stock And Grouping Terms
MBEW, "Material Valuation
T023T, "Material Group Desc.
MAKT, "Material Description
EKPO. "Purchasing Document Item.
DATA : BEGIN OF T_HEADER OCCURS 0,
MTART LIKE MARA-MTART,
MATNR LIKE MBEW-MATNR,
BWKEY LIKE MBEW-BWKEY,
MATKL LIKE MARA-MATKL,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
LBKUM LIKE MBEW-LBKUM,
SALK3 LIKE MBEW-SALK3,
VERPR LIKE MBEW-VERPR,
CLSTK LIKE MBEW-LBKUM,
CLVAL LIKE CKMLCR-SALK3,
UNIT LIKE CKMLCR-PVPRS,
END OF T_HEADER.
DATA : BEGIN OF T_MSEG OCCURS 0,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
BUDAT LIKE MKPF-BUDAT,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
ZEILE LIKE MSEG-ZEILE,
LFBNR LIKE MSEG-LFBNR,
LFBJA LIKE MSEG-LFBJA,
LFPOS LIKE MSEG-LFPOS,
BWART LIKE MSEG-BWART,
MENGE LIKE MSEG-MENGE,
EBELN LIKE MSEG-EBELN,
EBELP LIKE MSEG-EBELP,
XAUTO LIKE MSEG-XAUTO,
UMMAT LIKE MSEG-UMMAT,
UMWRK LIKE MSEG-UMWRK,
MARK(1),
END OF T_MSEG.
TYPE-POOLS : SLIS.
DATA : L_STOCK TYPE MSEG-MENGE.
DATA : WA_MSEG LIKE T_MSEG.
DATA : WA_MSEG1 LIKE T_MSEG.
DATA : T_ITEMS LIKE T_MSEG OCCURS 0 WITH HEADER LINE.
DATA : T_CUR_STOCK LIKE T_MSEG OCCURS 0 WITH HEADER LINE.
DATA : L_LBKUM TYPE MBEW-LBKUM.
DATA : BEGIN OF T_OUTPUT OCCURS 0,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
MENGE LIKE MSEG-MENGE,
PDAYS TYPE I,
PVAL TYPE MSEG-MENGE,
MAKTX LIKE MAKT-MAKTX,
CQTY LIKE MSEG-MENGE,
CPRC LIKE MBEW-SALK3,
END OF T_OUTPUT.
DATA: GRID_TAB TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA : T_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV.
*AT SELECTION-SCREEN.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-014.
SELECTION-SCREEN SKIP 1.
PARAMETERS : P_DATE LIKE S032-LETZTABG OBLIGATORY DEFAULT SY-DATUM.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK 1.
SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE TEXT-015.
PARAMETERS : P_WERKS TYPE S032-WERKS OBLIGATORY.
SELECT-OPTIONS : S_LGORT FOR S032-LGORT,
S_MATNR FOR S032-MATNR.
SELECTION-SCREEN END OF BLOCK 2.
SELECTION-SCREEN BEGIN OF BLOCK 3 WITH FRAME TITLE TEXT-016.
SELECT-OPTIONS : S_MTART FOR S032-MTART,
S_MATKL FOR S032-MATKL.
SELECTION-SCREEN END OF BLOCK 3.
IF P_DATE IS INITIAL AND
P_WERKS IS INITIAL AND
S_LGORT IS INITIAL AND
S_MATNR IS INITIAL AND
S_MTART IS INITIAL AND
S_MATKL IS INITIAL.
MESSAGE I398(00) WITH 'Enter Selection Critirea'(019).
SY-SUBRC = '1'.
ELSE.
SELECT AMATNR ABWKEY BMATKL BMTART CMAKTX BMEINS A~LBKUM
A~SALK3
INTO CORRESPONDING FIELDS OF TABLE T_HEADER
FROM MBEW AS A INNER JOIN MARA AS B ON AMATNR = BMATNR
INNER JOIN MAKT AS C ON AMATNR = CMATNR
WHERE A~MATNR IN S_MATNR
AND A~BWKEY EQ P_WERKS
AND MATKL IN S_MATKL
AND MTART IN S_MTART
AND BWTAR EQ ' '
AND C~SPRAS = SY-LANGU.
IF SY-SUBRC EQ 0.
SELECT ABUDAT AMBLNR AMJAHR BZEILE BMATNR BWERKS B~BWART
BMENGE BLFBNR BLFBJA BLFPOS BEBELN BEBELP B~XAUTO
BUMMAT BUMWRK
INTO CORRESPONDING FIELDS OF TABLE T_MSEG
FROM MKPF AS A INNER JOIN MSEG AS B ON AMBLNR = BMBLNR
AND AMJAHR = BMJAHR
FOR ALL ENTRIES IN T_HEADER
WHERE A~BUDAT <= P_DATE
AND B~MATNR = T_HEADER-MATNR
AND B~WERKS = T_HEADER-BWKEY
AND B~BWART IN ('101',
'102',
'105',
'106',
'122',
'123',
'301',
'302',
'701',
'702',
'131',
'132',
'309',
'310',
'501',
'502',
'531',
'532',
'561',
'562').
PERFORM GET_DEAD_STOCK.
PERFORM DISPLAY_OUTPUT.
ELSE.
MESSAGE S398(00) WITH 'No Data found for'(013)
'Given Selection Critirea'(017).
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
*& Form get_dead_stock
text
FORM GET_DEAD_STOCK .
LOOP AT T_HEADER.
SORT T_MSEG BY MATNR WERKS BUDAT DESCENDING MBLNR DESCENDING.
LOOP AT T_MSEG WHERE MATNR = T_HEADER-MATNR
AND WERKS = T_HEADER-BWKEY
AND ( BWART = '101' OR
BWART = '105' OR
BWART = '501' OR
BWART = '531' OR
BWART = '561' OR
BWART = '701' OR
BWART = '309' OR
BWART = '301' OR
BWART = '131' ).
IF T_MSEG-BWART = 101.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 102.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
READ TABLE T_MSEG INTO WA_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 122.
IF SY-SUBRC = 0.
READ TABLE T_MSEG INTO WA_MSEG1 WITH KEY LFBNR = WA_MSEG-MBLNR
LFBJA = WA_MSEG-MJAHR
LFPOS = WA_MSEG-ZEILE
BWART = 123.
IF SY-SUBRC EQ 0.
WA_MSEG-MARK = 'X'.
MODIFY T_MSEG FROM WA_MSEG.
CONTINUE.
ELSE.
IF T_MSEG-MENGE EQ WA_MSEG-MENGE.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ELSE.
T_MSEG-MENGE = T_MSEG-MENGE - WA_MSEG-MENGE.
MODIFY T_MSEG.
ENDIF.
ENDIF.
ENDIF.
ELSEIF T_MSEG-BWART = 105.
READ TABLE T_MSEG INTO WA_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 106.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 131.
READ TABLE T_MSEG INTO WA_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 132.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 501.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 502.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 301.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 302.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 531.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 532.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 561.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 562.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 701.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 702.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ELSEIF T_MSEG-BWART = 309.
READ TABLE T_MSEG WITH KEY LFBNR = T_MSEG-MBLNR
LFBJA = T_MSEG-MJAHR
LFPOS = T_MSEG-ZEILE
BWART = 310.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ELSEIF T_MSEG-XAUTO = ' '.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ELSEIF T_MSEG-MATNR EQ T_MSEG-UMMAT.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
ENDIF.
SELECT SINGLE EBELN INTO EKPO-EBELN FROM EKPO
WHERE EBELN = T_MSEG-EBELN
AND EBELP = T_MSEG-EBELP
AND KNTTP = 'K'.
IF SY-SUBRC = 0.
T_MSEG-MARK = 'X'.
MODIFY T_MSEG.
CONTINUE.
ENDIF.
TMENGE = TMENGE - t_mseg-MENGE.
ENDLOOP.
ENDLOOP.
DELETE T_MSEG WHERE MARK = 'X'.
DELETE T_MSEG WHERE ( BWART = '102' OR
BWART = '106' OR
BWART = '502' OR
BWART = '532' OR
BWART = '562' OR
BWART = '702' OR
BWART = '310' OR
BWART = '302' OR
BWART = '123' OR
BWART = '122' OR
BWART = '132' ).
SORT T_HEADER BY MATNR BWKEY.
DELETE ADJACENT DUPLICATES FROM T_HEADER COMPARING MATNR BWKEY.
T_CUR_STOCK[] = T_MSEG[].
SORT T_CUR_STOCK BY MATNR WERKS.
LOOP AT T_CUR_STOCK.
WA_MSEG = T_CUR_STOCK.
AT END OF WERKS.
ENDAT.
ENDLOOP.
LOOP AT T_HEADER.
CLEAR L_LBKUM.
L_LBKUM = T_HEADER-LBKUM.
REFRESH T_ITEMS.
CLEAR T_ITEMS.
LOOP AT T_MSEG WHERE MATNR EQ T_HEADER-MATNR
AND WERKS EQ T_HEADER-BWKEY.
T_ITEMS = T_MSEG.
APPEND T_ITEMS.
CLEAR T_ITEMS.
ENDLOOP.
SORT T_ITEMS BY BUDAT DESCENDING
MBLNR DESCENDING.
CLEAR L_LBKUM.
LOOP AT T_ITEMS.
L_LBKUM = T_ITEMS-MENGE - T_HEADER-LBKUM.
IF L_LBKUM GE 0.
T_OUTPUT-MATNR = T_HEADER-MATNR.
T_OUTPUT-WERKS = T_HEADER-BWKEY.
T_OUTPUT-BUDAT = T_ITEMS-BUDAT.
T_OUTPUT-MENGE = T_HEADER-LBKUM.
APPEND T_OUTPUT.
CLEAR T_OUTPUT.
EXIT.
ELSE.
T_HEADER-LBKUM = T_HEADER-LBKUM - T_ITEMS-MENGE.
T_OUTPUT-MATNR = T_HEADER-MATNR.
T_OUTPUT-WERKS = T_HEADER-BWKEY.
T_OUTPUT-BUDAT = T_ITEMS-BUDAT.
T_OUTPUT-MENGE = T_ITEMS-MENGE.
APPEND T_OUTPUT.
CLEAR T_OUTPUT.
CONTINUE.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. " get_dead_stock
*& Form DISPLAY_OUTPUT
text
FORM DISPLAY_OUTPUT .
DATA: L_DAYS TYPE I.
DATA : WA_OUTPUT LIKE T_OUTPUT.
DATA : T_FINAL LIKE T_OUTPUT OCCURS 0 WITH HEADER LINE.
DATA : WA_FINAL LIKE T_OUTPUT.
DATA : L_CQTY TYPE MSEG-MENGE,
L_CPRC TYPE MBEW-SALK3.
DATA : L_TITLE TYPE LVC_TITLE.
DATA : L_NAME1 TYPE T001W-NAME1.
*C-- Not to output when the quantity is zero.
DELETE T_OUTPUT WHERE MENGE EQ 0.
SORT T_OUTPUT BY WERKS MATNR BUDAT.
LOOP AT T_OUTPUT.
T_FINAL = T_OUTPUT.
AT NEW MATNR.
CLEAR T_HEADER.
READ TABLE T_HEADER WITH KEY MATNR = T_OUTPUT-MATNR
BWKEY = T_OUTPUT-WERKS.
ENDAT.
T_FINAL-MAKTX = T_HEADER-MAKTX.
IF T_HEADER-LBKUM GT 0.
T_FINAL-PVAL = ( T_OUTPUT-MENGE * T_HEADER-SALK3 / T_HEADER-LBKUM ).
ELSE.
CLEAR T_FINAL-PVAL.
ENDIF.
L_CQTY = L_CQTY + T_OUTPUT-MENGE.
IF T_HEADER-LBKUM GT 0.
L_CPRC = L_CPRC + ( T_OUTPUT-MENGE * T_HEADER-SALK3 / T_HEADER-LBKUM ).
ENDIF.
CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
EXPORTING
BEG_DA = T_OUTPUT-BUDAT
END_DA = P_DATE
IMPORTING
NO_CAL_DAY = L_DAYS
EXCEPTIONS
DATEINT_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE : 70 'Error While Calculating days'(018) .
ELSE.
T_FINAL-PDAYS = L_DAYS.
ENDIF.
T_FINAL-CQTY = L_CQTY.
T_FINAL-CPRC = L_CPRC.
APPEND T_FINAL.
AT END OF MATNR.
CLEAR : L_CPRC, L_CQTY.
ENDAT.
ENDLOOP.
PERFORM BUILD_FIELD_CATALOG.
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-SPOS = '1'.
APPEND WA_SORT TO T_SORT.
SELECT SINGLE NAME1 FROM T001W INTO L_NAME1
WHERE WERKS = P_WERKS.
CONCATENATE 'Plant: ' P_WERKS ',' L_NAME1 INTO L_TITLE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_GRID_TITLE = L_TITLE
IT_FIELDCAT = GRID_TAB[]
IT_SORT = T_SORT
I_SAVE = 'A'
TABLES
T_OUTTAB = T_FINAL[].
SORT T_FINAL BY WERKS MATNR BUDAT.
LOOP AT T_FINAL.
WRITE : /10 T_FINAL-MATNR.
WRITE : 30 T_FINAL-WERKS.
WRITE : 40 T_FINAL-BUDAT.
WRITE : 50 T_FINAL-MENGE.
**C-- FM to find the number of days between
**C-- todays date and the posting date
CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
EXPORTING
BEG_DA = T_FINAL-BUDAT
END_DA = P_DATE
IMPORTING
NO_CAL_DAY = L_DAYS
EXCEPTIONS
DATEINT_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE : 70 'Error While Calculating days'(018) .
ELSE.
WRITE : 70 L_DAYS.
ENDIF.
AT END OF MATNR.
ULINE.
READ TABLE T_HEADER WITH KEY MATNR = T_FINAL-MATNR
BWKEY = T_FINAL-WERKS.
IF SY-SUBRC EQ 0.
WRITE : /1 'Total Valuated Stock', T_HEADER-LBKUM.
WRITE : /1 'Value of total valuated Stock', T_HEADER-SALK3.
ULINE.
ENDIF.
ENDAT.
ENDLOOP.
ENDFORM. " DISPLAY_OUTPUT
*& Form BUILD_FIELD_CATALOG
text
--> p1 text
<-- p2 text
FORM BUILD_FIELD_CATALOG .
DATA : CNT1 TYPE I.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Material'.
GRID_TAB-FIELDNAME = 'MATNR'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Material Description'.
GRID_TAB-FIELDNAME = 'MAKTX'.
GRID_TAB-OUTPUTLEN = '30'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Date of Reciept'.
GRID_TAB-FIELDNAME = 'BUDAT'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Quantity'.
GRID_TAB-FIELDNAME = 'MENGE'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Pending Days'.
GRID_TAB-FIELDNAME = 'PDAYS'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Value'.
GRID_TAB-FIELDNAME = 'PVAL'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Cumulative Quantity'.
GRID_TAB-FIELDNAME = 'CQTY'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
CLEAR GRID_TAB.
CNT1 = CNT1 + 1.
GRID_TAB-COL_POS = CNT1.
GRID_TAB-SELTEXT_L = 'Value of Cumulative Quantity'.
GRID_TAB-OUTPUTLEN = '30'.
GRID_TAB-FIELDNAME = 'CPRC'.
GRID_TAB-KEY = 'X'.
GRID_TAB-NO_ZERO = 'X'.
GRID_TAB-TABNAME = 'T_FINAL'.
APPEND GRID_TAB.
ENDFORM. " BUILD_FIELD_CATALOG -
CLOSING STOCK FOR A GIVEN PERIOD
hi all,
I have to design a report to find out the closing stock.How to find out closing stock for say 1st nov to 15th nov.In MBEW and MCHB , i am getting closing stock as on date. please help me out if there are any tables or any other way out through function modules.
Regards,
Devinahi,
I will check that t code.
thanks and regards,
Devina
Maybe you are looking for
-
Automatic Creation of Settlement Rule for Maintenance Order
Hi, While doing TECO for Maintenance Order, its asking for Settlement Rule. IF I click settlement rule, message is coming as Maintain Settlement Profile with options like With Default, Without Default & Cancel. I have maintained the Cost center in Eq
-
Validation not working when Issue is modified
We have picklist field Action on which we have put a field validation which will ensure that depending on the Job title of the logged User, he will be able to select appropriate Action value. The problem we are facing is : The validation is not trigg
-
How do I set a path in an executable for a DLL?
I wrote a VI that is using a DLL in the Call Function Library Node. I set the parameters to Specify Path In Program in the node. I did this because I am distributing the VI as an executable and the path is obviously not the same as my VI. When runnin
-
How do I add songs to Itunes 12 playlist?
My computer operating system is Windows Vista. How to I add songs to a playlist in iTunes 12?
-
Need to clear my user id and personal information to give my computer to a friend?
I need to clear my computer of all personal information and user id etc. so i can give to someone else?