SELECT DISTINCT h.BUSINESS_UNIT , h.REQ_NAME FROM PS_REQ_HDR h WHERE h.HOLD_STATUS = 'N' AND h.BUDGET_HDR_STATUS = 'V' AND h.IN_PROCESS_FLG = 'N' AND (EXISTS ( SELECT 'X' FROM PS_REQ_LINE L , PS_REQ_LN_SHP_VW2 SV WHERE L.BUSINESS_UNIT = h.BUSINESS_UNIT AND L.REQ_ID = h.REQ_ID AND L.BUSINESS_UNIT = SV.BUSINESS_UNIT AND L.REQ_ID = SV.REQ_ID AND L.LINE_NBR = SV.LINE_NBR AND L.CURR_STATUS = 'A' AND L.INV_ITEM_ID = ' ' AND L.RFQ_IND = 'N' AND L.IN_PROCESS_FLG = 'N' AND L.SOURCE_DATE <= %CurrentDateIn AND L.SOURCE_STATUS = 'A' AND SV.BAL_STATUS = 'I' AND L.INVENTORY_SRC_FLG <> 'Y' AND (SV.QTY_OPEN > 0 OR SV.AMT_OPEN > 0)) OR EXISTS ( SELECT 'X' FROM PS_REQ_LINE L , PS_REQ_LN_SHP_VW2 SV , PS_PURCH_ITEM_ATTR P WHERE L.BUSINESS_UNIT = h.BUSINESS_UNIT AND L.REQ_ID = h.REQ_ID AND L.BUSINESS_UNIT = SV.BUSINESS_UNIT AND L.REQ_ID = SV.REQ_ID AND L.LINE_NBR = SV.LINE_NBR AND L.ITM_SETID = P.SETID AND L.INV_ITEM_ID = P.INV_ITEM_ID AND L.CURR_STATUS = 'A' AND L.RFQ_IND = 'N' AND L.IN_PROCESS_FLG = 'N' AND L.SOURCE_STATUS = 'A' AND L.SOURCE_DATE <= %CurrentDateIn AND L.INVENTORY_SRC_FLG <> 'Y' AND SV.BAL_STATUS = 'I' AND (SV.QTY_OPEN > 0 OR SV.AMT_OPEN > 0)))
|