ABAP--将数字金额转换为人民币大写字符串

2006年09月05日 16:10:00

function z_convert_numeric_to_chinese.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(PI_MONEY) LIKE BSEG-DMBTR
*" EXPORTING
*" REFERENCE(PO_CHINESE)
*" EXCEPTIONS
*" WRONG_MONEY
*"----------------------------------------------------------------------
if pi_money = 0.
po_chinese = '零'.
exit.
endif.
data:money_str(13).
money_str = pi_money.
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:po_chinese,units_off.
lastd = 0.
curnt_off = strlen( money_str ) - 1.
while curnt_off <= 0.
curntd = money_str+curnt_off(1).
i = curntd * 2.
cword = digts+i(2).

weight = units+units_off(2).


i = units_off / 2.
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 po_chinese into po_chinese.
lastd = curntd.
subtract 1 from curnt_off.
add 2 to units_off.
endwhile.
if po_chinese ns '分'.
concatenate po_chinese '整' into po_chinese.
else.
cword = po_chinese.
if cword = '零'.
shift po_chinese by 2 places.
endif.
endif.
endfunction.



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1180463


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值