*&---------------------------------------------------------------------* *& 抬头 : 汇率解析 * *& 模块 : FI * *& 作者 : 88392028 * *& 创建日期 : 2018/06/21 * *& 程序类型 : 汇率解析接口 * *& 消息类 : 00 * *& 描述 : 汇率解析 * *& 修改记录 : * *& 日期 修改人 修改内容 * *& 2018/09/10 88392028 二期优化 * *&---------------------------------------------------------------------* function zdq_fi_186 . *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(CURRENCY1) TYPE CHAR6 OPTIONAL *" VALUE(PAYTIME) TYPE SYDATE OPTIONAL *" VALUE(CURRENCY) TYPE CHAR6 OPTIONAL *" VALUE(COSTFLAGE) TYPE CHAR2 OPTIONAL *" EXPORTING *" VALUE(ROE_RATE) TYPE CHAR15 *" VALUE(COSTFLAGE) TYPE CHAR2 *" VALUE(FFACT) TYPE CHAR15 *" VALUE(TFACT) TYPE CHAR15 *" VALUE(JS_RATE) TYPE CHAR15 *" VALUE(OUT_STATUS) TYPE CHAR1 *" VALUE(OUT_MSG) TYPE CHAR255 *"---------------------------------------------------------------------- data: ls_tcurf like tcurf, ls_exch_rate type bapi1093_0. **s1.COSTFLAGE回写[字段名一致] **s2.TCURF表取FFACT,TFACT select single * into ls_tcurf from tcurf "汇率-转换因子 where kurst = 'M' and fcurr = currency1 and tcurr = currency. if sy-subrc eq 0. ffact = ls_tcurf-ffact. tfact = ls_tcurf-tfact. **s3.函数取汇率 call function 'BAPI_EXCHANGERATE_GETDETAIL' exporting rate_type = 'M' from_curr = ls_tcurf-fcurr "从货币 to_currncy = ls_tcurf-tcurr "到货币 date = paytime importing exch_rate = ls_exch_rate. * IF SY-SUBRC EQ 0. *****V1.0CHANGE BY 88392028 FOR XXX AT 20180910 BEGIN***** if ls_exch_rate-exch_rate is not initial. *****V1.0CHANGE BY 88392028 FOR XXX AT 20180910 E N D***** out_status = 'S'. roe_rate = ls_exch_rate-exch_rate. **[公式] JS_RATE = ROE_RATE * 转换因子-到 / 转换因子-从 if ls_tcurf-ffact is not initial. js_rate = roe_rate * ls_tcurf-tfact / ls_tcurf-ffact. else. out_msg = 'R3汇率解析/转换因子从TCURF-FFACT为0,计算汇率没取到值'. endif. else. out_status = 'E'. concatenate 'R3汇率解析/' currency1 '/' paytime '/' currency '/' costflage '/' '通过函数取汇率值失败' into out_msg. endif. else. out_status = 'E'. concatenate 'R3汇率解析/' currency1 '/' paytime '/' currency '/' costflage '/' '取转换因子TCURF表失败' into out_msg. endif. endfunction.