SELECT S.OPRID , I.BUSINESS_UNIT , I.CUST_ID , CASE S.RESP_PART_OPT WHEN 'A' THEN SR1.SETID WHEN 'B' THEN SR5.SETID WHEN 'R' THEN SR2.SETID WHEN 'S' THEN SR3.SETID ELSE SR4.SETID END , CASE S.RESP_PART_OPT WHEN 'A' THEN I.AR_SPECIALIST WHEN 'B' THEN I.BROKER_ID WHEN 'R' THEN I.CR_ANALYST WHEN 'S' THEN I.SALES_PERSON ELSE I.COLLECTOR END , I.TRANS_CURRENCY , I.BAL_AMT , I.ITEM_CNT , %Round(%DecDiv(%DecMult(I.BAL_AMT, A.RATE_MULT), A.RATE_DIV), CD.DECIMAL_POSITIONS) , S.DISPLAY_CURRENCY FROM PS_DBTIT_ITSMY_MVW I , PS_ARFO_PRF_DBTIT S , PS_SET_CNTRL_REC SR1 , PS_SET_CNTRL_REC SR2 , PS_SET_CNTRL_REC SR3 , PS_SET_CNTRL_REC SR4 , PS_SET_CNTRL_REC SR5 , PS_RT_RATE_TBL A , PS_RT_INDEX_TBL B , PS_CURRENCY_CD_TBL CD WHERE SR1.SETCNTRLVALUE = I.BUSINESS_UNIT AND SR1.RECNAME = 'AR_SPECIALIST' AND SR2.SETCNTRLVALUE = I.BUSINESS_UNIT AND SR2.RECNAME = 'CR_ANALYST_TBL' AND SR3.SETCNTRLVALUE = I.BUSINESS_UNIT AND SR3.RECNAME = 'TEAM_MEMBER_VW' AND SR4.SETCNTRLVALUE = I.BUSINESS_UNIT AND SR4.RECNAME = 'COLLECTOR_TBL' AND SR5.SETCNTRLVALUE = I.BUSINESS_UNIT AND SR5.RECNAME = 'CUSTOMER' AND A.FROM_CUR = I.TRANS_CURRENCY AND A.TO_CUR = S.DISPLAY_CURRENCY AND A.RT_TYPE = S.DSP_RT_TYPE AND A.RT_RATE_INDEX = B.RT_RATE_INDEX AND A.TERM = 0 AND B.DEFAULT_INDEX = 'Y' AND A.EFFDT = ( SELECT MAX(C.EFFDT) FROM PS_RT_RATE_TBL C , PS_RT_INDEX_TBL D WHERE D.DEFAULT_INDEX = 'Y' AND C.RT_RATE_INDEX = D.RT_RATE_INDEX AND C.TERM = 0 AND C.FROM_CUR = A.FROM_CUR AND C.TO_CUR = A.TO_CUR AND C.RT_TYPE = A.RT_TYPE AND C.EFFDT <= %CurrentDateIn ) AND CD.CURRENCY_CD = S.DISPLAY_CURRENCY AND CD.EFFDT = ( SELECT MAX(CD2.EFFDT) FROM PS_CURRENCY_CD_TBL CD2 WHERE CD2.CURRENCY_CD = CD.CURRENCY_CD AND CD2.EFF_STATUS = 'A' AND CD2.EFFDT <= %CurrentDateIn )
|