SELECT DISTINCT D.BUSINESS_UNIT_GL , B.SETID , A.VENDOR_ID , A.VNDR_LOC FROM PS_VENDOR_LOC A , PS_SET_CNTRL_REC B , PS_VENDOR C , PS_BUS_UNIT_TBL_AP D WHERE A.EFF_STATUS = 'A' AND (A.ACCT_TEMPL_FLG = 'D' OR A.DST_CNTRL_ID <> ' ') AND A.SETID = B.SETID AND B.RECNAME = 'VENDOR' AND C.VENDOR_STATUS = 'A' AND C.INTERUNIT_VNDR_FLG = 'Y' AND C.VNDR_AFFILIATE = D.BUSINESS_UNIT_GL AND C.SETID = B.SETID AND C.VENDOR_ID = A.VENDOR_ID AND A.EFFDT = ( SELECT MAX(C.EFFDT) FROM PS_VENDOR_LOC C WHERE A.SETID = C.SETID AND A.VENDOR_ID = C.VENDOR_ID AND A.VNDR_LOC = C.VNDR_LOC AND A.EFFDT <= %CurrentDateIn)
|