FUNCTION zf_cn_num.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(IV_MONEY) TYPE BSEG-DMBTR
*" EXPORTING
*" REFERENCE(EV_MONEY) TYPE CHAR100
*"----------------------------------------------------------------------
IF iv_money = 0.
ev_money = '零'.
EXIT.
ENDIF.
DATA:money_str(33).
money_str = iv_money.
CONDENSE money_str NO-GAPS.
IF money_str CN '0123456789. '.
RAISE wrong_money.
ENDIF.
DATA:i TYPE i.
IF money_str CS '.'.
i = sy-fdpos + 1.
money_str+sy-fdpos = money_str+i.
ENDIF.
CONDENSE money_str NO-GAPS.
DATA:units_off TYPE i,
curnt_off TYPE i.
DATA:lastd TYPE n,curntd TYPE n.
DATA:cword(2),weight(2).
DATA:units(30) VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万',
digts(20) VALUE '零壹贰叁肆伍陆柒捌玖'.
* clear:ev_money,units_off.
lastd = 0.
curnt_off = strlen( money_str ) - 1.
WHILE curnt_off >= 0.
curntd = money_str+curnt_off(1).
i = curntd.
cword = digts+i(1).
weight = units+units_off(1).
i = units_off / 1.
IF curntd = 0. "Current digit is 0
IF i = 2 OR i = 6 OR i = 10.
CLEAR:cword.
IF curnt_off = 0.
CLEAR:weight.
ENDIF.
ELSEIF lastd = 0.
CLEAR:cword,weight.
ELSE.
CLEAR:weight.
ENDIF.
ENDIF.
CONCATENATE cword weight ev_money INTO ev_money.
lastd = curntd.
SUBTRACT 1 FROM curnt_off.
ADD 1 TO units_off.
ENDWHILE.
IF ev_money NS '分'.
CONCATENATE ev_money '整' INTO ev_money.
ELSE.
cword = ev_money.
IF cword = '零'.
SHIFT ev_money BY 1 PLACES.
ENDIF.
ENDIF.
ENDFUNCTION.
ABAP货币大小写转换函数
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 8.3.1 去除空格和字符串填补及大小写转换函数 去除空格和字符串填充补函数 函数:ltrim( )语法: str...
- 键-值观察实现细节(Apple 文档:https://developer.apple.com/library/ma...