SAP ABAP MARD和MARDH计算逻辑
mard里记载的是当前库存的数量,但是期间并不一定是当月。比如你物料4月一整月都没有库存数量变化(没收没发),那么5月初你看mard里的条目期间数还是4月而非5月。
当某个期间发生货物移动的时候,系统在更新mard数据的之前(这个表是实时更新的),会检查此笔业务过账期间和mard里对应记录的期间是否一致,也就是看这是不是本期间第一笔移动。如果是,copy表mard里对应记录到mardh,然后把mard记录改成当期(也可能是先删后建),然后再作更新数量数据的操作。如果不是第一笔记录,也就是mard期间和mseg期间一致,则不作copy记录只更新mard数量。
这样处理貌似减少了冗余数据,不过给编程取历史库存增加了很大的工作量,个人觉得不算明智之举。
计算常用料月结库存的首选透明表:
MARD:物料仓储位置的当前库存数据
MARDH:物料仓储库存的历史数据
其存数逻辑如下:
Scenario
At the start of period 02, there are 10 pieces of material A100 in stock.
Goods receipt
5 pieces are received in period 02.
System response
The system records(生成一条记录) a stock of 10 pieces in the history table (MARDH) for period 01. At the same time, the system increases the current stock to 15 pieces (MARD).
Goods receipt
2 more pieces are received in period 02.
System response
The history table is unaffected by this event because an entry already exists for period 01. The system increases the current stock to 17 pieces (MARD).
Goods issue
4 pieces are withdrawn from stock in period 04.
System response
The system records(生成一条记录) a stock of 17 pieces in the history table (MARDH) for period 03. At the same time, the system reduces the current stock to 13 pieces.
注:The history table (MARDH)does not contain an entry for period 02 because there were no goods movements in period 03.