Skip to Content

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 table History table Function module
Material Valuation MBEW MBEWH MBEW_EXTEND
Storage Location Data for Material MARD MARDH MARD_EXTEND
Batch Stocks MCHB MCHBH MCHB_EXTEND
Project Stock Valuation QBEW QBEWH QBEW_EXTEND
Special Stocks with Customer MSKU MSKUH MSKU_EXTEND
Special Stocks with Vendor MSLB MSLBH MSLB_EXTEND
Sales Order Stock Valuation EBEW EBEWH EBEW_EXTEND
Special Stocks from Vendor MKOL MKOLH MKOL_EXTEND
Project Stock MSPR MSPRH MSPR_EXTEND
Material Master Plant data MARC MARCH MARC_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.


MB51_.JPG

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

MB51.JPG

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.


To report this post you need to login first.

27 Comments

You must be Logged on to comment or reply to a post.

  1. Nilesh Kshatriya

    hi Jurgan,

    Thank you very much for giving conceptual clarification..

    As per my understanding/study, the stock and value updated in history table for one perticular material is same as of closing stock and value which we can see in MB5B for that material at month end date.

    Regds,

    Nilesh

    (0) 
    1. Jürgen L Post author

      Thanks, that is my aim: to explain complex things in a way that it can be understood by everyone.

      I do not like the doctor language of explaining things extra complicated to preserve the status of a special breed

      (0) 
  2. Jürgen L Post author

    50 is the correct quantity.

    Remember, the table is MBEWH which means valuated stock

    the receipt of 2 is not to stock, there is no storage location, it is a receipt to a PO with account assignment.

    (0) 
  3. Manish Shandilya

    Hi Jurgen,

    Thanks for sharing this document, It helps a lot to understand this complex picture.

    I have one thing to ask what yo mean by receipt of 2 is not to stock , it is receipt to a PO with Account assignment. What is the difference between them.

    Thanks,

    Manish

    (0) 
    1. Adrián Ruiz

      A little bit late but; when making a Goods Receipt that comes from a PO with acount assignment the “destination” of the material being received is not the Warehouse (or what you called “not to stock”).

      The destination of that material is what the user indicated in the account assignment field in the PO, some of those account assignment “objects” are (as configured in my system):

      A    Asset

      B    MTS prod./sales ord.

      C    Sales order

      D    Indiv.cust./project

      E    Ind. cust. w. KD-CO

      F    Order

      G    MTS prod./project

      H    Third-party GR mand.

      K    Cost center

      M    Ind. cust. w/o KD-CO

      N    Network

      P    Project

      Q    Proj. make-to-order

      R    Services 2 Way match

      T    All new aux.acc.***.

      U    Unknown

      V    All aux. w/ GR mand.

      W    Vendor Consignment

      X    All aux.acct.assgts.

      Y    Third-party Order

      Z    MTO valuated with RA

      One good example is a purchase directed to a Cost Center (K); the value of the purchase will affect directly the Cost Center indicated in the PO, and you won´t see quantity being received at any storage location as those “goods” where delivered directly to the responsible of that Cost Center (business area).

      Regards,

      Adrian

      (0) 
  4. Arijit Ghose

    Hello

    Not sure if I missed the point above, but is it possible to read historical stocks (say, 2 years ago) directly through the FM MBEW_EXTEND or MARD_EXTEND? Is there any option programmatically to read these stocks?

    SAP standard has reports like MB5B / MC.9 etc that can help out; however, often we need to fetch these values in a report; is there an API available that could help us here?

    Thanks

    Arijit

    (0) 
    1. Jürgen L Post author

      Do you not consider function modules as programs? MBEW_EXTEND can read 2 year old stock, MARD_EXTEND cannot.

      From OSS note 415349: Not all function modules can calculate these periods. Correspondingly not all function modules have all four parameters.

      (0) 
      1. Arijit Ghose

        Hello Juergen

        Thanks for your note. I meant if these FMs can’t do it, is there any other option programmatically?

        Coming back to your point on the FM MBEW_EXTEND, could you tell me how we could read old stocks thru this FM. I tried using this FM with all different parameters and passing the current row from MBEW in MBEW_TAB as advised in the Note 415349, but it kept returning me the same line item. Do we need to go back period by period? Let’s take an example, the MBEW record I have is for 03/2014, and the last record in MBEWH is for 02/2014. Can I read 02/2012 stock through this FM directly?

        Regards

        Arijit

        (0) 
        1. Simon Rehr

          hi arijit,

          i got the same issue. get sales order stock quantity to a given date in the past ( period ).

          if you need the coding just answer. i know, its a little bit time past 😉

          regards,

          Simon

          (0) 
  5. Jürgen L Post author

    The first March posting should create this February entry, if it was posted in the March period and not backdated to post in February period.

    First search for OSS notes, if there is no suitable then open a call yourself

    (0) 
    1. Juwin Pallipat Thomas

      Sorry Jurgen, I thought my question was in an inappropriate place and hence had deleted my comment before you could reply.

      For the readers,

      Jurgen was replying to my following query:

      We had some materials + batches, where we found that the history table entries were missing eventhough the 1st transaction in the new period has happened. I was asking him why this would have happened and if I should log a call to SAP for fixing this.

      I logged an incident with SAP and they confirmed my finding that the history table entries were in fact missing. They created the missing entries manually.

      Thanks.

      (0) 
  6. Vivek S

    Dear Jurgen Sir,

    Really appreciated article and very informative…not only for functional it also very useful from technical perspective too.

    Regards,

    Vivek

    (0) 
  7. Jürgen L Post author

    No, not directly as this is just about month end stocks and how the records in the historic tables work.
    You were looking for a transaction, you can just copy your subject line into Google to find what you asked for.

    (0) 
  8. Dammah Sebiyam

    Hi Jurgen,

    Guten Tag,

    I need a pointer here. I got my developer write a code in HANA to generate inventory (Valuated stock) from MBEW, MBEWH, EBEW, EBEWH, CKMLCR etc. Basically to generate period end inventory values. When this report is run for current period for a plant the values tie with GL.  The difficulty is running it for previous periods like behavior in MB5L or S_P99_41000062 or any other inventory report.

    What are key fields SAP is using to look up or loop back for values in these tables for previous periods.  We triedMBEWH-LFMON, MBEWH-LFGJA.  Any pointer as to how my developer can code into HANA so when a report is run for say, previous period, logic is able to determine last value for each stock in each plant and return the same?

    Thank you

    (0) 

Leave a Reply