SELECT a.business_unit , a.po_id , a.po_dt , b.vendor_name_short , b.vendor_id , b.name1 , a.vndr_loc , SUM(c.merchandise_amt) , a.currency_cd FROM ps_po_hdr_fs a , ps_vendor b , PS_PO_LINE_SHIP_FS c WHERE a.vendor_setid = b.setid AND a.vendor_id = b.vendor_id AND ((a.po_status = 'D') OR ((a.chng_ord_batch > 0) AND a.po_status = 'D')) AND a.ers_action = 'N' AND a.match_status_po IN ('T','P','N') AND a.in_process_flg = 'N' AND a.mid_roll_status = 'N' AND a.business_unit = c.business_unit AND a.po_id = c.po_id AND c.match_status_ln_po IN ('N', 'P') AND A.BUDGET_HDR_STATUS = 'V' AND A.BUDGET_HDR_STS_NP = 'V' AND A.CC_USE_FLAG IN ('N',' ') AND EXISTS ( SELECT 'X' FROM PS_PO_LINE_DIST_FS E WHERE E.BUSINESS_UNIT = C.BUSINESS_UNIT AND E.PO_ID = C.PO_ID AND E.LINE_NBR = C.LINE_NBR AND E.DST_ACCT_TYPE = 'DST' AND E.KK_CLOSE_FLAG <> 'Y') AND EXISTS ( SELECT 'X' FROM PS_PO_LINE_FS PO_LN WHERE PO_LN.BUSINESS_UNIT = C.BUSINESS_UNIT AND PO_LN.PO_ID = C.PO_ID AND PO_LN.LINE_NBR = C.LINE_NBR) AND NOT EXISTS ( SELECT 'X' FROM PS_RECV_LN_SHIP_FS F WHERE F.BUSINESS_UNIT_PO = A.BUSINESS_UNIT AND F.PO_ID = A.PO_ID AND F.SERIAL_CONTROL = 'Y' AND F.SERIAL_STATUS = 'I' AND F.recv_ship_status <> 'X') GROUP BY a.business_unit, a.po_id, a.po_dt, b.vendor_name_short, b.vendor_id, b.name1, a.vndr_loc, a.currency_cd
|