SELECT DISTINCT A.BUSINESS_UNIT , A.ORDER_NO , A.ORDER_INT_LINE_NO , A.SCHED_LINE_NBR , A.DEMAND_LINE_NO FROM PS_IN_DEMAND A , PS_BU_ITEMS_INV B WHERE A.DEMAND_SOURCE IN ('IN', 'PL', 'PR') AND A.INTERUNIT_FLG = 'Y' AND (A.IN_FULFILL_STATE IN ('20', '30', '40', '50') 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 EXISTS ( SELECT 'X' FROM PS_IN_DEMAND_HASH C , PS_IN_PEGGING D WHERE C.BUSINESS_UNIT = A.BUSINESS_UNIT AND C.DEMAND_SOURCE = A.DEMAND_SOURCE AND C.SOURCE_BUS_UNIT = A.SOURCE_BUS_UNIT AND C.ORDER_NO = A.ORDER_NO AND C.ORDER_INT_LINE_NO = A.ORDER_INT_LINE_NO AND C.SCHED_LINE_NBR = A.SCHED_LINE_NBR AND C.INV_ITEM_ID = A.INV_ITEM_ID AND C.DEMAND_LINE_NO = A.DEMAND_LINE_NO AND C.HASH_KEY = D.SUPPLY_HASH AND D.SUP_ORDER_TYPE = '035'))) AND A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.INV_ITEM_ID = B.INV_ITEM_ID
|