SELECT DISTINCT (SELECT segment1
FROM mtl_system_items_b
WHERE inventory_item_id = mmt.inventory_item_id
AND ROWNUM < 2) item,
mmt.organization_id inv_org_id, mmt.transaction_id,
SUM (mmt.transaction_quantity) quantity,
mmt.transaction_date,
mmt.subinventory_code AS subinventory_from,
mmt.transfer_subinventory AS subinventory_to,
mmt.attribute8 AS dc_no, mmt.attribute9 AS dc_date,
mmt.move_order_line_id,
(SELECT header_id
FROM mtl_txn_request_lines
WHERE line_id = mmt.move_order_line_id
AND ROWNUM < 2) mo_number,
mmt.locator_id from_locator_id,
mmt.transfer_locator_id to_locator_id,
(SELECT lot_number
FROM mtl_transaction_lot_numbers
WHERE transaction_id = mmt.transaction_id
AND ROWNUM < 2) lot_number,
(SELECT NVL (origination_date, creation_date)
FROM mtl_transaction_lot_numbers
WHERE transaction_id = mmt.transaction_id
AND ROWNUM < 2) lot_date,
mmt.new_cost COST
FROM mtl_material_transactions mmt
WHERE 1 = 1
AND mmt.transaction_quantity < 0
AND mmt.transaction_action_id IN (1, 2)
AND TRUNC (mmt.transaction_date) BETWEEN TRUNC (SYSDATE
- 180
)
AND TRUNC (SYSDATE)
AND mmt.transaction_type_id = 64 -- MO Transfer
GROUP BY mmt.organization_id,
mmt.inventory_item_id,
mmt.transaction_type_id,
mmt.transaction_date,
mmt.subinventory_code,
mmt.transfer_subinventory,
mmt.attribute8,
mmt.attribute9,
mmt.move_order_line_id,
mmt.new_cost,
mmt.transaction_id,
mmt.locator_id,
transfer_locator_id;
FROM mtl_system_items_b
WHERE inventory_item_id = mmt.inventory_item_id
AND ROWNUM < 2) item,
mmt.organization_id inv_org_id, mmt.transaction_id,
SUM (mmt.transaction_quantity) quantity,
mmt.transaction_date,
mmt.subinventory_code AS subinventory_from,
mmt.transfer_subinventory AS subinventory_to,
mmt.attribute8 AS dc_no, mmt.attribute9 AS dc_date,
mmt.move_order_line_id,
(SELECT header_id
FROM mtl_txn_request_lines
WHERE line_id = mmt.move_order_line_id
AND ROWNUM < 2) mo_number,
mmt.locator_id from_locator_id,
mmt.transfer_locator_id to_locator_id,
(SELECT lot_number
FROM mtl_transaction_lot_numbers
WHERE transaction_id = mmt.transaction_id
AND ROWNUM < 2) lot_number,
(SELECT NVL (origination_date, creation_date)
FROM mtl_transaction_lot_numbers
WHERE transaction_id = mmt.transaction_id
AND ROWNUM < 2) lot_date,
mmt.new_cost COST
FROM mtl_material_transactions mmt
WHERE 1 = 1
AND mmt.transaction_quantity < 0
AND mmt.transaction_action_id IN (1, 2)
AND TRUNC (mmt.transaction_date) BETWEEN TRUNC (SYSDATE
- 180
)
AND TRUNC (SYSDATE)
AND mmt.transaction_type_id = 64 -- MO Transfer
GROUP BY mmt.organization_id,
mmt.inventory_item_id,
mmt.transaction_type_id,
mmt.transaction_date,
mmt.subinventory_code,
mmt.transfer_subinventory,
mmt.attribute8,
mmt.attribute9,
mmt.move_order_line_id,
mmt.new_cost,
mmt.transaction_id,
mmt.locator_id,
transfer_locator_id;
No comments:
Post a Comment