SELECT DISTINCT OH.BUSINESS_UNIT , OS.SHIP_FROM_BU , OH.ORDER_NO FROM PS_ORD_SCHEDULE OS , PS_ORD_HEADER OH , PS_ORD_HEADER_LOCK K WHERE OS.BUSINESS_UNIT = OH.BUSINESS_UNIT AND OS.ORDER_NO = OH.ORDER_NO AND %Join(COMMON_KEYS, ORD_HEADER OH, ORD_HEADER_LOCK K) AND K.BACKGROUND_REQD = 'N' AND K.HOLD_REQD = 'N' AND K.CREDIT_REQD = 'N' AND OH.ORDER_TYPE_CD = 'SO' AND OH.ORDER_STATUS <> 'C' AND K.PROCESS_INSTANCE = 0 AND (OS.DEMAND_SENT = 'N' OR (OS.DEMAND_SENT = 'Y' AND (EXISTS ( SELECT 'X' FROM PS_ORD_SCH_PEND_VW PND WHERE %Join(COMMON_KEYS, ORD_SCH_PEND_VW PND, ORD_SCHEDULE OS) AND PND.SHIP_FROM_BU = OS.SHIP_FROM_BU AND PND.DROP_SHIP_FLAG = 'N' AND PND.INVENTORY_ITEM = 'Y') OR EXISTS ( SELECT 'X' FROM PS_ORD_SCH_PNDK_VW PNDK WHERE %Join(COMMON_KEYS, ORD_SCH_PNDK_VW PNDK, ORD_SCHEDULE OS) AND PNDK.SHIP_FROM_BU = OS.SHIP_FROM_BU AND PNDK.DROP_SHIP_FLAG = 'N' AND PNDK.INVENTORY_ITEM = 'Y'))))
|