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 @ 2022-11-24 14:08  YangMeiko  阅读(231)  评论(0)    收藏  举报