SAP 外币金额问题汇总

获取SAP汇率

OB08配置的汇率

复制代码
复制代码
          CALL FUNCTION 'READ_EXCHANGE_RATE'
            EXPORTING
              client           = sy-mandt
              date             = p_datuv          "当前日期
              foreign_currency = gw_output-konwa  "外币
              local_currency   = 'CNY'
              type_of_rate     = 'M'
              exact_date       = ' '
            IMPORTING
              exchange_rate    = lv_rate.
          IF sy-subrc <> 0.
* Implement suitable error handling here
          ENDIF.
复制代码
复制代码

外币显示   获取转换因子 如JPY 越南币

复制代码
        CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR'
                  EXPORTING
                    currency          = gw_output-konwa
                  IMPORTING
                    factor            = l_factor
                  EXCEPTIONS
                    too_many_decimals = 1
                    OTHERS            = 2.
        IF sy-subrc <> 0.
* Implement suitable error handling here
        ENDIF.
        gw_output-price =  gw_output-price * l_factor.
复制代码

外部金额转内部金额

复制代码
        IF gw_output-konwa <> 'CNY'.
          CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
            EXPORTING
              date             = p_datuv
              foreign_amount   = gw_output-price_js  "外部金额  必须是两位小数
              foreign_currency = gw_output-konwa     "币种 
              local_currency   = 'CNY'
*             rate             = gw_output-zhl
              type_of_rate     = 'M'
            IMPORTING
              local_amount     = gw_output-kbetr
            EXCEPTIONS
              no_rate_found    = 1
              OTHERS           = 2.

        ELSE.
          gw_output-kbetr =  gw_output-price.

        ENDIF.
复制代码

 汇率获取

复制代码
 CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
    EXPORTING
      rate_type  = 'P'
      from_curr  = lv_waers
      to_currncy = 'CNY'
      date       = lv_datum
    IMPORTING
      exch_rate  = ls_exch.
*        return     = ls_return.
复制代码

 

posted @   YangMeiko  阅读(130)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示