Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
JL23
Active Contributor
138,228

All stock and valuation tables in SAP have as well history tables since release 45. All those tables have the same name as the standard tables, but with a H at the end.


Standard tableHistory tableFunction module
Material ValuationMBEWMBEWHMBEW_EXTEND
Storage Location Data for MaterialMARDMARDHMARD_EXTEND
Batch StocksMCHBMCHBHMCHB_EXTEND
Project Stock ValuationQBEWQBEWHQBEW_EXTEND
Special Stocks with CustomerMSKUMSKUHMSKU_EXTEND
Special Stocks with VendorMSLBMSLBHMSLB_EXTEND
Sales Order Stock ValuationEBEWEBEWHEBEW_EXTEND
Special Stocks from VendorMKOLMKOLHMKOL_EXTEND
Project StockMSPRMSPRHMSPR_EXTEND
Material Master Plant dataMARCMARCHMARC_EXTEND
and some more



This was implemented to speed up the period closing.

But how these tables are updated is for many users cumbersome, they expect to see a record for each month in those history tables, but SAP does it differently. SAP explains the logic in Note 193554 - Stock/valuation data of previous periods still we can see in many discussions that this note was not fully understood.

SAP does not update the history table when you execute MMPV to close the MM period.

The History tables are updated with first movement after a period closure.

If there is no movement for several months, then you will not see any history record for all those months that have past.

SAP writes only a history record for the month preceding a change in stock or value.

All the periods between 2 records in a history table had the same stock/value all the time, hence you can take the value for those periods from the record following these missing periods.

Here we see 8 history records for the valuation data MBEW of one material in one plant, created over a time span of 5 years:

many would expect to see 60 records for 5 years, but we had only 8 months with changes in those 5 years, hence only 8 history records were created.


And as proof a screen shot from MB51 Material Document list for the same material and plant:

You can see that the first movement to this material happened on May 22, 2007. This event triggered the creation of the history record for period 004 2007.

The history record tells you that the stock and value for this material was zero at the end of April 2007

The next month with movements was December 2007, which caused a history record for November 2007

The movement from April 8, 2008 triggered the creation of 2 history records: for period 003 2008, and because there was a year change in between a record for period 12 2007

The  movement type 301K (marked yellow) did not trigger any update in MBEWH table, because consignment stock has no value, hence no change to valuation, which means MBEW table is not affected.

Finally we have movements in May 2011, and the first movement caused the creation of year end records of 2009 and 2010 and for the previous month 04 2011.

If you need to develop own ABAP reports with month end stock then you have to make use of function modules that understand this complex logic. The name of these function modules is starting with the table name followed by _EXTEND (see table)

To retrieve previous period data for all materials in valuation area ZRAG the coding should be like that


select * from mbew into table mbew_tab where bwkey = 'ZRAG'.

call function 'MBEW_EXTEND'

    exporting

      xvper = 'X'

    tables

      mbew_tab = mbew_tab.

Please read the SAP Note 415349 - Usage of modules XXXX_EXTEND for previous period values for detailed information because the function modules are not released.


33 Comments
Labels in this area