[Reprint] data update logic of the mbewh table

Source: Internet
Author: User

The mbewh table is updated regardless of whether the moving average price map is changed.

The mbewh table records the historical data of the mbew table, while the mbew table is the material valuation table.

The mbew table records the current material price. When the material price is re-evaluated (such as updating the current moving average price of the material), the SAP system writes the current price to the mbewh table, and write the new price into mbew.

The current price is always recorded in the table mbew. When the first operation in a period (period) updates the quantity or value of materials, the SAP system writes a record to the table mbewh, based on the balance and price control before the first operation.

In the mbewh table, the numbers recorded during the previous period are stored in the "current period" lfmon field.

For example, when the first transfer (such as receipt) occurs during the period 3, the system writes the number 2 to the "current period" lfmon field in the mbewh table, the quantity and value are updated to the "Total stock" and "total value" fields, and are equal to the quantity and value that occurred during the 3 period.

If no posting is made for several consecutive periods, mbewh does not create records for each period.

Differences between mbew, mbewh and mchbh:

Mbew: view the moving average price of the Current billing period

Mbewh: view the moving average price of the historical billing period

The table mbewh records all inventory values, while the table mchbh only represents the value of unlimited' inventory.

How to view the current moving average price:

TransactionsCode: S_p00_07000139

The latest moving average price after each material re-evaluation.

Appendix: Note 193554
Summary
As of release 4.5, stock and valuation fields that refer to the previous period or those dating back even farther, are not stored in those tables in which the current stock data is stored (mbew, MARD, mchb, and so on) but in so-called history tables (mbewh, mardh, mchbh, and so on .).
(Also compare release note for period closing as of release 4.5)
These history tables can have one entry per period. the values of such an entry refer to the end of the period. for the current period, there are no entries in the History tables. an entry is not written in this history table for every period. if stock-relevant or valuation-relevant data change, the system might generate an entry in the History Table.
Furthermore, the fields lfmon ('current period (booking period) ') and lfgja ('fiscal year of the current period ') in the stock tables are no longer automatically set to the current period by the period closing program. the period is only transferred to the new period during the first movement. at the same time, the relevant history entries are also generated.

Example:
Material 4711 has a stock of 10 pieces at the end of period 01
In period 02, a goods receept of 5 pieces occurs.
Now, an entry is added in the History Table for period 01 with a stock of 10 pieces. simultaneously, the current stock is increased to 15 pieces and the 'current period 'field (lfmon) is set to 02.
In period 02, an additional goods receept occurs with 2 pieces.
The history table is not affected by this operation since an entry already exists for period 01. The current stock is increased to 17 pieces.
In period 04, a goods issue of 4 pieces occurs.
Now, the system adds an entry for period 03 with a stock of 17 pieces in the History Table. simultaneously, the current stock is decreased to 13 pieces and the 'current period 'field (lfmon) is changed from 02 to 04.
Since no goods movement has occurred in period 03, there is no entry for period 02 in the History Table.

Thus, the following applies:

1. the stock in the stock table describes the situation since the last goods movement which changed this segment. the period of this movement appears in the fields lfmon and lfgja. all stocks for periods which are earlier than the periods given in the fields lfmon and lfgja relate to the current stocks and can be found in the stock tables.

2. If for a previous period N, no entry exists in the History table, then the values of this period correspond to the values of the period N + 1.

Since the 2nd rule can be used recursively, under consideration of the two above rules the values can be determined for any periods of that period in which release 4.5 or a higher release were implemented.

Please note: Since the history tables are not created into actively, the history entries only exist in their completed form from the time from which users work with the new period cloprogram. the periods for which the period closing program has run for the first time with history records are listed in the table Marv for every company code in the fields gja_40c and mon_40c. for technical reasons it is possible that there are also entries in the History tables with an older period. nevertheless, these entries are not available without gaps for all stocks.
this algorithm is also implemented in function modules mbew_extend, mard_extend and so on. these function modules are used in the standard SAP programs in order to determine the values of the previous period and to extend tables with the reference structure mbew, MARD and so on correspondingly.

If you have your own programs which use the prior-period values from the tables MARD, mbew Etc ., you shoshould call up the relevant extend component after reading the data from the table. this then returns the data as though no change had taken place in the previous logic. you can then remove the prior-period values from the known fields.

Additional key words
Mbewh, mardh, mchbh, stock information, previous period stock, previous month stock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.