SELECT DISTINCT A.BUSINESS_UNIT , A.ORDER_NO FROM PS_IN_DEMAND A , PS_BU_ITEMS_INV B WHERE A.DEMAND_SOURCE = 'OM' AND A.INTERUNIT_FLG = 'N' AND (EXISTS ( SELECT 'X' FROM PS_DF_SETUP_IT_INV WHERE BUSINESS_UNIT = A.BUSINESS_UNIT AND INV_ITEM_ID = A.INV_ITEM_ID AND SOFT_ALLOC_FLG = 'Y') OR (NOT EXISTS ( SELECT 'X' FROM PS_DF_SETUP_IT_INV WHERE BUSINESS_UNIT = A.BUSINESS_UNIT AND INV_ITEM_ID = A.INV_ITEM_ID AND SOFT_ALLOC_FLG = 'Y') AND EXISTS ( SELECT 'X' FROM PS_DF_SETUP_INV WHERE BUSINESS_UNIT = A.BUSINESS_UNIT AND SOFT_ALLOC_FLG = 'Y'))) AND (A.APPROVED_FLAG = 'Y' OR (A.APPROVED_FLAG = 'N' AND PEG_STATUS = '10')) AND ((A.QTY_REQUESTED_BASE - A.QTY_ALLOC_BASE - A.QTY_BACKORDER_BASE > 0 AND IN_FULFILL_STATE = '20') OR PEG_STATUS IN ('10', '20')) AND A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.INV_ITEM_ID = B.INV_ITEM_ID
|