SELECT DISTINCT A.BUSINESS_UNIT , A.VOUCHER_ID , A.VOUCHER_LINE_NUM , A.BUSINESS_UNIT_PO , A.PO_ID , A.LINE_NBR , A.SCHED_NBR FROM PS_VCHR_MTCH_DETLS A , PS_AP_MTCH_EXCPTN B , PS_VOUCHER C WHERE A.PROCESS_INSTANCE = B.PROCESS_INSTANCE AND A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.VOUCHER_ID = B.VOUCHER_ID AND A.VOUCHER_LINE_NUM = B.VOUCHER_LINE_NUM AND A.BUSINESS_UNIT = C.BUSINESS_UNIT AND A.VOUCHER_ID = C.VOUCHER_ID AND C.MATCH_STATUS_VCHR IN ('E', 'O', 'D') AND A.PROCESS_INSTANCE IN ( SELECT DISTINCT MAX(PROCESS_INSTANCE) FROM PS_VCHR_MTCH_DETLS WHERE BUSINESS_UNIT = A.BUSINESS_UNIT AND VOUCHER_ID = A.VOUCHER_ID AND VOUCHER_LINE_NUM = A.VOUCHER_LINE_NUM AND BUSINESS_UNIT_PO = A.BUSINESS_UNIT_PO AND PO_ID = A.PO_ID AND LINE_NBR = A.LINE_NBR AND SCHED_NBR = A.SCHED_NBR AND BUSINESS_UNIT_RECV = A.BUSINESS_UNIT_RECV AND RECEIVER_ID = A.RECEIVER_ID AND RECV_LN_NBR = A.RECV_LN_NBR AND RECV_SHIP_SEQ_NBR = A.RECV_SHIP_SEQ_NBR GROUP BY BUSINESS_UNIT, VOUCHER_ID, VOUCHER_LINE_NUM)
|