SELECT A.BUSINESS_UNIT , A.GRP_AP_ID , A.ASSIGNED_TO_OPRID FROM PS_GRP_AP A WHERE EXISTS ( SELECT 'X' FROM PS_VOUCHER B , PS_VCHR_ACCTG_LINE C WHERE B.BUSINESS_UNIT = A.BUSINESS_UNIT AND B.GRP_AP_ID = A.GRP_AP_ID AND B.BUSINESS_UNIT = C.BUSINESS_UNIT AND B.VOUCHER_ID = C.VOUCHER_ID AND ((B.MATCH_ACTION='N') OR (B.MATCH_ACTION='Y' AND B.MATCH_STATUS_VCHR IN ('M','O')) OR (B.MATCH_ACTION = 'Y' AND B.MATCH_STATUS_VCHR = 'T' AND B.CLOSE_STATUS = 'C')) AND C.ASSET_FLG = 'Y' AND C.AM_DISTRIB_STATUS IN ('M', 'N'))
|