ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 低值货币的转换

低值货币的转换

原创 Linux操作系统 作者:hzq2010 时间:2011-04-11 20:50:52 0 删除 编辑
SAP中有些低值货币存储的时候是缩小的,在显示的时候会自动进行转换。
这里牵涉到货币的放大转换,SAP中有标准的置换程式,可以用形如以下例子的语句进行调用:
write gv currency 'JPY'
gv 是p或是i类型的值,也就是一些货币值等。'JPY'就是货币单位,此处是日元。
 
实际上你在对数据表进行操作的时候,可以直接调用函数来处理这些没有小数点的币种,TWD,KOR JPY===

BAPI_CURRENCY_CONV_TO_EXTERNAL

BAPI_CURRENCY_CONV_TO_INTERNAL

 
可以调用FM CURRENCY_CONVERTING_FACTOR 获取存储时的缩放因子。
data:      p_intval like wmto_s-amount.   "Internal Amount
  data:      gd_disval  like wmto_s-amount. "Display Amount

  call function 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
       exporting
            currency        = po_tab-waers
            amount_internal = p_intval
       importing
            amount_display  = gd_disval
       exceptions
            internal_error  = 1
            others          = 2.
DATA: gd_fcurr TYPE tcurr-fcurr,
      gd_tcurr TYPE tcurr-tcurr,
      gd_date  TYPE sy-datum,
      gd_value TYPE i.

gd_fcurr = 'EUR'.
gd_tcurr = 'GBP'.
gd_date  = sy-datum.
gd_value = 10.

PERFORM. currency_conversion USING gd_fcurr
                                  gd_tcurr
                                  gd_date
                         CHANGING gd_value.



* Convert value to Currency value
*&---------------------------------------------------------------------*
*&      Form. currency_conversion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GD_FCURR  text
*      -->P_GD_TCURR  text
*      -->P_GD_DATE   text
*      <--P_GD_VALUE  text
*----------------------------------------------------------------------*
FORM. currency_conversion  USING    p_fcurr
                                   p_tcurr
                                   p_date
                          CHANGING p_value.

  DATA: t_er        TYPE tcurr-ukurs,
        t_ff        TYPE tcurr-ffact,
        t_lf        TYPE tcurr-tfact,
        t_vfd       TYPE datum,
        ld_erate(12)   TYPE c.

  CALL FUNCTION 'READ_EXCHANGE_RATE'
    EXPORTING
*       CLIENT                  = SY-MANDT
      date                    = p_date
      foreign_currency        = p_fcurr
      local_currency          = p_tcurr
      TYPE_OF_RATE            = 'M'
*       EXACT_DATE              = ' '
   IMPORTING
      exchange_rate           = t_er
      foreign_factor          = t_ff
      local_factor            = t_lf
      valid_from_date         = t_vfd
*       DERIVED_RATE_TYPE       =
*       FIXED_RATE              =
*       OLDEST_RATE_FROM        =
   EXCEPTIONS
     no_rate_found           = 1
     no_factors_found        = 2
     no_spread_found         = 3
     derived_2_times         = 4
     overflow                = 5
     zero_rate               = 6
     OTHERS                  = 7
            .
  IF sy-subrc EQ 0.
    ld_erate = t_er / ( t_ff / t_lf ).
    p_value = p_value * ld_erate.
  ENDIF.
ENDFORM.                    " currency_conversion

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23495244/viewspace-692256/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 计划订单批导
请登录后发表评论 登录
全部评论

注册时间:2010-03-11

  • 博文量
    196
  • 访问量
    168095