1.當前的庫存量
select MOH.ORGANIZATION_ID,
MOH.SUBINVENTORY_CODE,
MOH.INVENTORY_ITEM_ID,
SUM(MOH.PRIMARY_TRANSACTION_QUANTITY) ONHAND_QTY,
(SELECT SUM(MMT.TRANSACTION_QUANTITY)
FROM MTL_MATERIAL_TRANSACTIONS MMT
WHERE MMT.INVENTORY_ITEM_ID=MOH.INVENTORY_ITEM_ID
AND MMT.SUBINVENTORY_CODE=MOH.SUBINVENTORY_CODE
AND MMT.ORGANIZATION_ID=MOH.ORGANIZATION_ID
) A
from MTL_ONHAND_QUANTITIES_DETAIL moh
WHERE MOH.ORGANIZATION_ID=X
GROUP BY MOH.ORGANIZATION_ID, MOH.SUBINVENTORY_CODE,
MOH.INVENTORY_ITEM_ID
2.庫存異動數量
SELECT MMT.ORGANIZATION_ID,
MMT.INVENTORY_ITEM_ID,
MMT.SUBINVENTORY_CODE,
ITEMB.SEGMENT1 AS "item",
SUM(MMT.TRANSACTION_QUANTITY) TRANS_QTY
FROM MTL_MATERIAL_TRANSACTIONS MMT,
MTL_SYSTEM_ITEMS_B ITEMB
WHERE 1=1
AND MMT.ORGANIZATION_ID=ITEMB.ORGANIZATION_ID
AND MMT.INVENTORY_ITEM_ID=ITEMB.INVENTORY_ITEM_ID
AND MMT.ORGANIZATION_ID=X
GROUP BY MMT.ORGANIZATION_ID,
MMT.INVENTORY_ITEM_ID,
MMT.SUBINVENTORY_CODE,
ITEMB.SEGMENT1
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/41594/viewspace-50523/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/41594/viewspace-50523/