ABAP币种对应的转换因子(处理日元台币等)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
因为涉及到日元和台币问题,太久不写了,写了个小demo测了下
主要用的就是函数CURRENCY_CONVERTING_FACTOR
*&---------------------------------------------------------------------*
*& Report ZLM_0001
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zlm_0001.
DATA: lt_price TYPE zlm_t_curr.
DATA: ls_price LIKE LINE OF lt_price.
ls_price-price = 123.
ls_price-curr = 'USD'.
APPEND ls_price TO lt_price.
ls_price-price = '12.3'.
ls_price-curr = 'USD'.
APPEND ls_price TO lt_price.
ls_price-price = '12.31'.
ls_price-curr = 'USD'.
APPEND ls_price TO lt_price.
ls_price-price = 123.
ls_price-curr = 'TWD'.
APPEND ls_price TO lt_price.
ls_price-price = '12.3'.
ls_price-curr = 'TWD'.
APPEND ls_price TO lt_price.
ls_price-price = '12.31'.
ls_price-curr = 'TWD'.
APPEND ls_price TO lt_price.
DATA: lv_curr TYPE tcurr-tcurr.
DATA: lv_factor TYPE isoc_factor.
FIELD-SYMBOLS LIKE LINE OF lt_price.
LOOP AT lt_price ASSIGNING .
lv_curr= -curr.
CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR' EXPORTING
currency = lv_curr
IMPORTING
factor = lv_factor.
IF lv_factor IS NOT INITIAL.
-price = -price / lv_factor.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING
i_structure_name = 'ZLM_STR_CURR' TABLES
t_outtab = lt_price.
如果不加
LOOP AT lt_price ASSIGNING .
lv_price = -curr.
CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR' EXPORTING
currency = lv_price
IMPORTING
factor = lv_factor.
IF lv_factor IS NOT INITIAL.
-price = -price / lv_factor.
ENDIF.
ENDLOOP.
如果加上那段代码处理后