SELECT a.business_unit , a.voucher_id , a.invoice_id , b.vendor_name_short , b.name1 , a.invoice_dt FROM PS_VOUCHER a , ps_vendor b , PS_BUS_UNIT_TBL_AP C , PS_FIN_OPEN_PERIOD P WHERE a.vendor_setid = b.setid AND a.vendor_id = b.vendor_id AND A.BUSINESS_UNIT = C.BUSINESS_UNIT AND a.entry_status = 'P' AND a.in_process_flg = 'N' AND a.budget_hdr_status = 'V' AND a.budget_misc_status = 'V' AND A.DOC_TOL_HDR_STATUS = 'V' AND (a.process_man_close = 'Y' OR a.post_status_ap = 'U') AND A.POST_VOUCHER IN ('D', 'P') AND ((A.APPR_STATUS = 'A' AND A.VCHR_LINE_APPR IN ('0', '1')) OR (A.APPR_STATUS <> 'A' AND A.VCHR_LINE_APPR IN ('0', '1', '2') AND (C.POST_UNAPPRV_FLG = 'Y' OR A.PROCESS_MAN_CLOSE = 'Y'))) AND ((C.POST_UNMATCH_FLG = 'Y') OR (C.POST_UNMATCH_FLG = 'N' AND (a.MATCH_STATUS_VCHR = 'N' OR a.MATCH_STATUS_VCHR = 'M'))) AND P.PSFT_PRODUCT = 'AP' AND P.BUSINESS_UNIT = a.BUSINESS_UNIT AND ((a.post_status_ap = 'U' AND a.process_man_close <> 'Y' AND P.OPEN_FROM_DATE <= a.ACCOUNTING_DT AND P.OPEN_TO_DATE >= a.ACCOUNTING_DT) OR (a.POST_STATUS_AP = 'P' AND a.PROCESS_MAN_CLOSE = 'Y' AND P.OPEN_FROM_DATE <= a.MANUAL_CLOSE_DT AND P.OPEN_TO_DATE >= a.MANUAL_CLOSE_DT) OR (a.POST_STATUS_AP = 'U' AND a.PROCESS_MAN_CLOSE = 'Y' AND P.OPEN_FROM_DATE <= a.ACCOUNTING_DT AND P.OPEN_TO_DATE >= a.ACCOUNTING_DT AND P.OPEN_FROM_DATE <= a.MANUAL_CLOSE_DT AND P.OPEN_TO_DATE >= a.MANUAL_CLOSE_DT))
|