取匯率

*&---------------------------------------------------------------------*
*& 擡頭     : 匯率解析                                                 *
*& 模塊     : 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.
相關文章
相關標籤/搜索