在SAP中各种币种的金额都是默认2位小数,比如人民币、美元,但是有些币种是不存在小数位的,如日元、韩元,于是SAP中增加了一个币种转换因子的概念,透明表存储数据时是按实际金额*10的(n-2)次方存储,有条目但未维护小数位的默认小数位为0,小数位维护的值为1-5,配置路径如下:
以日元JPY和越南盾VND做测试凭证为例:F-02做凭证时按照10000金额录入,FB03显示金额为10000,透明表BSEG中JPY存储的金额为100000,VND存储金额为100,
程序中金额转换的几种方式:
- 使用function module CURRENCY_CONVERTING_FACTOR进行转换
DATA:lv_wrbtr TYPE bseg-wrbtr. DATA:lv_factor TYPE p DECIMALS 3. SELECT SINGLE wrbtr INTO lv_wrbtr FROM bseg WHERE bukrs = '1210' AND belnr = '0100000006'. WRITE:/'JPY转换前:',lv_wrbtr. CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR' EXPORTING currency = 'JPY' IMPORTING factor = lv_factor EXCEPTIONS too_many_decimals = 1 OTHERS = 2 . IF sy-subrc = 0. lv_wrbtr = lv_wrbtr * lv_factor. WRITE:/'JPY转换后:',lv_wrbtr. ENDIF.
2.使用function module CURRENCY_AMOUNT_SAP_TO_DISPLAY或CURRENCY_AMOUNT_DISPLAY_TO_SAP进行转换
DATA:lv_amount TYPE wmto_s-amount.
SELECT SINGLE wrbtr INTO lv_amount FROM bseg WHERE bukrs = '1210' AND belnr = '0100000006'.
WRITE:/'JPY转换前:',lv_amount.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
EXPORTING
currency = 'JPY'
amount_internal = lv_amount
IMPORTING
amount_display = lv_amount
EXCEPTIONS
internal_error = 1
OTHERS = 2.
IF sy-subrc = 0.
WRITE:/'JPY转换后:',lv_amount.
ENDIF.