首页 > 其他分享 >测试数字金额 转为中文大写

测试数字金额 转为中文大写

时间:2022-12-13 12:01:11浏览次数:66  
标签:count 中文 temp tab3 转为 con2 大写 TYPE SY

测试数字金额 转为中文大写 


DATA:
money_text TYPE spell.

DATA:
con1(256) TYPE c,
con2(128) TYPE c,
con3(384) TYPE c.
DATA:
BEGIN OF it_tab3 OCCURS 0,
content TYPE c,
END OF it_tab3.
DATA:
con_temp TYPE c.
DATA:
count TYPE i.

count = 0.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = '12123456789.11'
CURRENCY = 'CNY'
* FILLER = ' '
LANGUAGE = '1'
IMPORTING
IN_WORDS = money_text
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CONCATENATE money_text-word '圆' INTO con1.

WHILE money_text-DECWORD+count(1) <> ''.
con_temp = money_text-DECWORD+count(1).

IF con_temp = '拾'.
it_tab3-content = '角'.

ELSE.
it_tab3-content = con_temp.

ENDIF.

APPEND it_tab3.
count = count + 1.

ENDWHILE.


LOOP AT it_tab3.
CONCATENATE con2 it_tab3-content INTO con2.

ENDLOOP.

IF con_temp <> '拾'. "判断是不是只有到 ‘角’ 位上有数字,如果是的话,con_temp 是的内容应该是 '拾' ,
"不是的话说明 '分' 位上有值,后面要加个 ’分‘
CONCATENATE con2 '分' INTO con2.

ENDIF.


**没有 角 和 分 即是 '.00' 情况
IF count = 1 AND con2 = '零分'.
con2 = ''.

ENDIF.

CONCATENATE con1 con2 INTO con3.

WRITE: /, con3.

标签:count,中文,temp,tab3,转为,con2,大写,TYPE,SY
From: https://blog.51cto.com/u_512327/5933787

相关文章