SELECT (select msib.segment1 || '|' || msib.segment2
from mtl_system_items_b msib
where msib.inventory_item_id = moq.inventory_item_id
and msib.organization_id = moq.organization_id ) PART_NUMBER,
moq.organization_id,
((SELECT ORGANIZATION_code
FROM org_organization_definitions odd
WHERE organization_name LIKE 'UET%'
AND odd.organization_id = moq.organization_id)) Org_code,
mr.reserve_quantity reserved_quantity,
moq.transaction_quantity - mr.reserve_quantity available_toreserve_qty,
moq.transaction_quantity
FROM ( SELECT moq.inventory_item_id inventory_item_id,
moq.organization_id organization_id,
SUM (moq.primary_transaction_quantity)
transaction_quantity
FROM mtl_onhand_quantities_detail moq
WHERE Moq.Organization_Id = nvl(:Organization_Id,Organization_Id)
-- AND moq.subinventory_code = 'XXXX'
GROUP BY moq.inventory_item_id, moq.organization_id) moq,
( SELECT SUM (primary_reservation_quantity) reserve_quantity,
inventory_item_id,
organization_id
FROM Mtl_Reservations
WHERE Organization_Id = nvl(:Organization_Id,Organization_Id)
-- AND subinventory_code = ' XXXX'
GROUP BY Organization_Id, inventory_item_id) mr
WHERE moq.inventory_item_id = mr.inventory_item_id
AND Moq.Organization_Id = Mr.Organization_Id
and Moq.Organization_Id in (SELECT ORGANIZATION_id
FROM org_organization_definitions odd
WHERE organization_name LIKE 'UET%')
No comments:
Post a Comment