[轉]MBEWH表數據更新邏輯

資料來源:http://www.saphow.com/html/82/n-82.html

無論移動平均價(Moving Average Price MAP)是否有更改,MBEWH表都會更新。

MBEWH表記錄了MBEW錶的歷史數據,而MBEW是物料評估(Material Valuation)表。

MBEW表記錄了當前的物料價格,當物料價格被重估(比如更新物料當前移動平均價)時,SAP系統會將當前價格寫入MBEWH表中,而將新價格寫入MBEW中。

當前的價格總是記錄在表MBEW中,當某一期間(Period)的第一項操作更新了物料數量或價值,則SAP系統會向表MBEWH寫入一條記錄,以第一項操作之前的餘額、價格控制爲標準。

在MBEWH表中代表上一期間記錄的數字儲存在“當前期間”LFMON字段中。

例:當在3期間發生第一筆過賬(比如收貨),則系統會在MBEWH表中的“當前期間”LFMON字段寫入數字2,數量和價值更新到“總庫存(Total Stock)”和“總價值(Total Value)”字段,並且等於發生在3期間的數量和價值。

若在連續幾個期間內未發生過賬,則表MBEWH不會爲每個期間創建記錄。

表MBEW、MBEWH與MCHBH的區別:

MBEW:查看當前賬期的移動平均價

MBEWH:查看歷史賬期的移動平均價

表MBEWH記錄了所有的庫存價值,而表MCHBH則只代表了未限制庫存的價值。

如何查看當前移動平均價:

事務代碼:S_P00_07000139

每次物料重估後的最新移動平均價。

附: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 receipt 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 receipt 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 retroactively, the history entries only exist in their completed form from the time from which users work with the new period closing program. 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 should 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

發佈了68 篇原創文章 · 獲贊 4 · 訪問量 38萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章