SELECT a.vendor_setid , b.vendor_id , a.business_unit , a.po_id , a.po_dt , b.vendor_name_short , b.name1 , 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 IN ('D','C') OR (a.chng_ord_batch > 0 AND a.po_status IN ('D','C'))) AND a.ers_action = 'N' AND a.in_process_flg = 'N' AND a.business_unit = c.business_unit AND a.po_id = c.po_id 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 WHERE BUSINESS_UNIT = C.BUSINESS_UNIT AND PO_ID = C.PO_ID AND LINE_NBR = C.LINE_NBR AND DST_ACCT_TYPE = 'DST' AND KK_CLOSE_FLAG <> 'Y') GROUP BY a.vendor_setid, b.vendor_name_short, b.vendor_id, b.name1, a.business_unit, a.po_id, a.po_dt, a.currency_cd
|