IT干货网

ABAP-金额小写转大写

shasha 2022年03月09日 SAP 146 0
"&----- 金额小转大,亿万元问题修复 ------------------

form frm_19_money_upper using fv_iv_money fv_ev_money. if fv_iv_money
= 0. fv_ev_money = ''. exit. endif. data:money_str(33). money_str = fv_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 '零壹贰叁肆伍陆柒捌玖'. data:lv_wan type i, lv_wst type string. * clear:fv_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. if i = 6. clear:lv_wan. lv_wan = strlen( money_str ) - 10. if lv_wan > 0. lv_wan = money_str+lv_wan(3). if lv_wan = 0. clear:weight. endif. endif. endif. elseif lastd = 0. clear:cword,weight. else. clear:weight. endif. endif. concatenate cword weight fv_ev_money into fv_ev_money. lastd = curntd. subtract 1 from curnt_off. add 1 to units_off. endwhile. if fv_ev_money ns ''. concatenate fv_ev_money '' into fv_ev_money. else. cword = fv_ev_money. if cword = ''. shift fv_ev_money by 1 places. endif. endif. endform.

评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

ABAP-ALV详解