function zfi_amount_to_upper.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IN) TYPE WERT8
*" EXPORTING
*" REFERENCE(OUT) TYPE STRING
*"----------------------------------------------------------------------
data:
v_s00(2) value '零',
v_s01(2) value '壹',
v_s02(2) value '贰',
v_s03(2) value '叁',
v_s04(2) value '肆',
v_s05(2) value '伍',
v_s06(2) value '陆',
v_s07(2) value '柒',
v_s08(2) value '捌',
v_s09(2) value '玖',
v_w00(2) value '',
v_w01(2) value '拾',
v_w02(2) value '佰',
v_w03(2) value '仟',
v_w04(2) value '万',
v_w05(4) value '拾',
v_w06(4) value '佰',
v_w07(4) value '仟',
v_w08(2) value '亿',
v_w09(4) value '拾',
v_w10(4) value '佰',
v_w11(4) value '仟',
v_w12(4) value '万',
v_sy(2) value '圆',
v_sj(2) value '角',
v_sf(2) value '分',
v_amount(16),"将金额转换成字符型
v_len type i,"v_amount或out的长度
v_var(5),"v_s0,v_s1,...,v_w0,v_w1,...
v_num(2) type n,"每一位的数值
v_s_num(2),"v_s0,v_s1,...中的值
v_weight(2) type n,"权数
v_w_num(4),"v_w0,v_w1,...中的值
v_flag0 type i value 0,"是否输出'零',0不输出,1输出
v_n type i value 0,
v_index type sy-index.
v_amount = in.
shift v_amount left deleting leading space.
shift v_amount left deleting leading '0'.
*-计算分-----------------------------------------
v_len = strlen( v_amount ).
v_len = v_len - 1.
v_num = v_amount+v_len(1).
if v_num <> '0'.
concatenate 'v_s' v_num into v_var.
write (v_var) to v_s_num.
concatenate v_s_num v_sf out into out.
endif.
*-计算角-----------------------------------------
v_len = strlen( v_amount ).
v_len = v_len - 2.
v_num = v_amount+v_len(1).
if v_num <> '0'.
concatenate 'v_s' v_num into v_var.
write (v_var) to v_s_num.
concatenate v_s_num v_sj out into out.
endif.
*-输出‘整’字-------------------------------------
if out = ' '.
concatenate '整' out into out.
endif.
*-计算整数---------------------------------------
v_len = strlen( v_amount ).
v_len = v_len - 3.
if v_len = 0.
exit.
endif.
v_amount = v_amount(v_len)." 整数部分
*-输出‘元’字-------------------------------------
concatenate v_sy out into out.
v_n = v_len - 1.
v_weight = 0.
do v_len times.
v_index = sy-index.
* 从个位开始
v_num = v_amount+v_n(1).
if v_num <> '0'.
concatenate 'v_s' v_num into v_var.
write (v_var) to v_s_num.
concatenate 'v_w' v_weight into v_var.
write (v_var) to v_w_num.
concatenate v_s_num v_w_num out into out.
v_flag0 = 1.
else.
if v_flag0 = 1.
concatenate 'v_s' v_num into v_var.
write (v_var) to v_s_num.
concatenate v_s_num out into out.
v_flag0 = 0.
endif.
if v_index = 5 and v_len > 5 and v_len < 9 .
concatenate '万' out into out.
elseif v_index = 9 and v_len > 9.
concatenate '亿' out into out.
endif.
* CASE SY-INDEX.
* WHEN 5.CONCATENATE '万' OUT INTO OUT.
* WHEN 9.CONCATENATE '亿' OUT INTO OUT.
* ENDCASE.
endif.
v_weight = v_weight + 1.
v_n = v_n - 1.
enddo.
*-删除个位可能出现'零'的情况-----------------
search out for '圆'.
if sy-subrc = 0.
v_n = sy-fdpos - 2.
if v_n >= 0.
if out+v_n(2) = v_s00.
v_len = strlen( out ).
concatenate out(v_n) out+sy-fdpos into out.
endif.
endif.
endif.
endfunction.