Skip to Content
Author's profile photo Jürgen Lins

Material Stock and Valuation History tables – how to read them

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
Storage Location Data for Material MARD MARDH MARD_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
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.


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’


      xvper = ‘X’


      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.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Very helpful.

      Thank you...

      Author's profile photo Former Member
      Former Member

      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.



      Author's profile photo Former Member
      Former Member

      I have been searching this information for long time.

      Thank you for your explanation



      Author's profile photo Mehmet Ozgur Unal
      Mehmet Ozgur Unal

      thanks jurgen ,

      this tables are as same as CO tables CKMLCR-CKMLPP

      i wiss, i could read stock and value updated based on day

      M.Ozgur UNAL

      Author's profile photo Mohsin Abbasi
      Mohsin Abbasi

      Hi Jurgen,

      Amazing One............. 😉

      Best Regards

      Mohsin Abbasi

      Author's profile photo PRASOON AK

      Hi Jurgen..

          Very informative and simple presentation.

          Thanks for sharing.



      Author's profile photo Jürgen L
      Jürgen L
      Blog 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

      Author's profile photo Former Member
      Former Member

      Excellent collection of tables, Good information thanks! Also you may wish to use MB5B Report (RM07MLBD) to inventory report beyond current and past period.

      Sunil Wawdhane

      Author's profile photo Jürgen L
      Jürgen L
      Blog 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.

      Author's profile photo Former Member
      Former Member

      Great document! Thanks for sharing!

      Author's profile photo Former Member
      Former Member

      amazing, quite a good one. Thanks for sharing.

      Author's profile photo Former Member
      Former Member

      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.



      Author's profile photo Former Member
      Former Member

      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).



      Author's profile photo Former Member
      Former Member

      very useful document

      Author's profile photo Former Member
      Former Member

      thanks a lot.

      Author's profile photo Former Member
      Former Member

      Helpful!  Thank you~

      Author's profile photo Chu Tien Thanh
      Chu Tien Thanh

      Very useful, thanks alot

      Author's profile photo Former Member
      Former Member


      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?



      Author's profile photo Jürgen L
      Jürgen L
      Blog 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.

      Author's profile photo Former Member
      Former Member

      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?



      Author's profile photo Simon Rehr
      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 😉



      Author's profile photo Jürgen L
      Jürgen L
      Blog 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

      Author's profile photo Juwin Pallipat Thomas
      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.


      Author's profile photo Former Member
      Former Member

      Dear Jurgen Sir,

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



      Author's profile photo Andreas Lindholm
      Andreas Lindholm

      Hi Jurgen...

      Is this the post you refered to in my deleted question regarding Historical values of customer consignment stock?

      Author's profile photo Jürgen L
      Jürgen L
      Blog 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.

      Author's profile photo Dammah Sebiyam
      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

      Author's profile photo Leon Cornelio
      Leon Cornelio

      Hi Jurgen,,


      In table MARDH and MARCH the value in current period value is blank.


      And because of this i am not able to do a system conversion.

      Author's profile photo Patrick Sekar
      Patrick Sekar

      Hello Jurgen,

      So while archiving of any material, if we get error "W4119 MBEW: stock value for previous year still exists" which is related to stock value in MBEWH, Should we clear the data in MBEWH table for previous year as given in notes - 532734/320665.

      Please advice if any impact is there after deleting data from MBEWH for previous year so as to archive the material




      Author's profile photo Fernando DE SALVO
      Fernando DE SALVO

      Thanks Júrgen

      Very clear and useful as usual

      I would like to share with you and example we have in our system for valuated project stock and my doubts about update of tables MSPRH and QBWEH







      MB51 for stock Q


      Issue for WBS element 76007 for 200 M done with material doc 52920932 on 04.06.2020 . QBEWH and MSPRH correctly updated for month 05.20. Thanks to your explanation that means that At end of this period I had 200 M in stock for that WBS. This stock now is gone trough the issue for 200 M

      On the other hand, actual stock in WBS 79610 is 2697 M as you can see in QBEW and MSPR, but never updated this value in tables QBEWH and MSPRH. Last movement 52274867 for that WBS was on 04.03.20 and this quantity remains equal until now. Following the logic yo explained is clear for me that in tables QBEWH and MSPRH effectively I have a record for period 02.20, but with zero stock. Shouldn´t have this record with 2687 M? More over considering no further movements were made against this WBS element

      Otherwise I suppose function moludules XXX_EXTEND wouldn´t work to calculate for example today the stocks at the end of period 06.20, which is my actual requirement.

      Appreciate your answer if you have a chance to review the case

      Best Regards

      Author's profile photo Fernando DE SALVO
      Fernando DE SALVO

      Hi Jürgen,

      Solved. You explained well. DON´T NEED TO REED PREVIOUS POST

      The thing is that the movement for 2697 M was the first for this specific WBS element, that´s why in QBEWH the record appears with zero value

      The only question I would like you to confirm is the following:

      If I use this functions XXX_EXTEND it´s sure that I will obtain all real values for the inmediate previous period, despite missing records or records with zero value for N previous periods in the historical tables?

      I mean this functions are prepared to manage this situations and give me always real values for the previous period to actual, with the parameter you mentioned right? If I execute them today (july 2020), they should return values at the end of 06.20 right? This is exactly what we need and I would like to confirm with you before devope.

      Thanks a lot again for your help

      Author's profile photo Jimmy Bamuteeze
      Jimmy Bamuteeze


      Can the total stock at the end of the period include the stock from the previous period?

      Author's profile photo Sergiu Iatco
      Sergiu Iatco

      Analyze how data are extracted from MBEWH in standard code.


        METHOD get_mbew.
          DATA: ls_mbew TYPE mbew,
                lt_mbew TYPE STANDARD TABLE OF mbew.
              matnr             = iv_matnr
              bwkey             = iv_bwkey
              bwtar             = iv_bwtar
              wmbew             = ls_mbew
              lock_on_mbew      = 1
              lock_system_error = 2
              wrong_call        = 3
              not_found         = 4
              OTHERS            = 5.
          IF sy-subrc <> 0.
            RAISE error_occured.
          APPEND ls_mbew TO lt_mbew.
              mbew_tab = lt_mbew.
          READ TABLE lt_mbew INTO rs_mbew INDEX 1.


      SE38: J_1GVL_WHBT14

      * LOGIC for accessing tables (as of 13/7/2001 no report available
      *       that shows how to properly access them, hence our labelling of
      *       this reposrt as a 'beta' version: (XXX = ARD, SLB, SKU)
      * MXXX has most recent period material was moved.
      * MXXXH is updated every time we have new movement.
      * Suppose now is 8/Y1, material has one movement (Q=10) in period 6/Y1.
      * then MXXX  says LFMON/LFGJA/Q 6/Y1/Q+10, Q = initial stock
      *      MXXXH says LFMON/LFGJA/Q 5/Y1/Q.
      * Now we have 3 cases:
      *  a) we want stock for any period >= 6/Y1. We get it from MXXX
      *  b) we want stock for 5/Y1. We Get it from MXXXH
      *  c) we want stock for < 5/Y1. We Get it from MXXXH for a FUTURE period
      *     hence the >= select. But, eg, MARDH may have many records for same
      *     MATNR/WERKS/LGORT combo so we must only get the less far in the
      *     future one...
        data tmbew like mbew occurs 1000 with header line.
        data hmbew like mbewh occurs 1000 with header line.
        select * from mbew into corresponding fields of table tmbew
          where matnr in s_matnr
          and   bwkey in r_bwkey
          and   bwtar in s_bwtar
          and   bklas in s_bklas
          and ( bwtty = space or
                ( bwtty ne space and bwtar ne space ) )
          and (   ( lfgja  = p_gjahr and lfmon <= p_monat )
               or ( lfgja  < p_gjahr                      ) ).
        select * from mbewh into corresponding fields of table hmbew
          where matnr in s_matnr
          and   bwkey in r_bwkey
          and   bwtar in s_bwtar
          and   bklas in s_bklas
          and (   ( lfgja = p_gjahr and lfmon >= p_monat )
               or ( lfgja > p_gjahr                      ) ).


      SE37: J_1A_READ_MBEWH

      FUNCTION j_1a_read_mbewh .
      *"*"Local Interface:
      *"  IMPORTING
      *"  EXPORTING
      *"  EXCEPTIONS
      *"      NO_VALUATION_DATA
        CLEAR es_mbewh.
        es_mbewh-matnr = is_mbew-matnr.
        es_mbewh-bwkey = is_mbew-bwkey.
        es_mbewh-bwtar = is_mbew-bwtar.
        "first check if required data is contained in IS_MBEW already:
        "if there were no postings for a material for a few periods you might not find an entry in MBEWH for IV_GJAHR and IV_PERIOD,
        "you must read the current values from MBEW -
        "see note 193554 for MBEWH logic
        IF is_mbew-lfgja = iv_gjahr AND is_mbew-lfmon <= iv_period OR is_mbew-lfgja < iv_gjahr.
          MOVE-CORRESPONDING is_mbew TO es_mbewh.
          IF iv_column_list <> 'PEINH'. "if only PEINH required skip first select for performance reasons
            SELECT (iv_column_list) FROM mbewh UP TO 1 ROWS
              INTO CORRESPONDING FIELDS OF es_mbewh
                matnr = is_mbew-matnr AND
                bwkey = is_mbew-bwkey AND
                bwtar = is_mbew-bwtar AND
                ( lfgja = iv_gjahr AND lfmon >= iv_period OR
                  lfgja > iv_gjahr )
              ORDER BY
                lfgja ASCENDING
                lfmon ASCENDING.
            IF sy-subrc <> 0.
              MOVE-CORRESPONDING is_mbew TO es_mbewh. "use MBEW entry since nothing better available
              RAISE no_valuation_data.
          IF es_mbewh-peinh = 0 AND ( iv_column_list = '*' OR iv_column_list CP '*PEINH*' ).
            "sometimes initial MBEWH entry does not contain price unit, therefore select from closest non-initial MBEWH entry
            SELECT peinh FROM mbewh UP TO 1 ROWS
              INTO CORRESPONDING FIELDS OF es_mbewh
                matnr = is_mbew-matnr AND
                bwkey = is_mbew-bwkey AND
                bwtar = is_mbew-bwtar AND
                ( lfgja = iv_gjahr AND lfmon >= iv_period OR
                  lfgja > iv_gjahr ) AND
                peinh <> 0
              ORDER BY
                lfgja ASCENDING
                lfmon ASCENDING.
            IF sy-subrc <> 0.
              es_mbewh-peinh = is_mbew-peinh.