FUNCTION zzfi_change_amount.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(I_MONEY) TYPE BF_DMBTR
*" EXPORTING
*" REFERENCE(O_MONEY)
*" EXCEPTIONS
*" WRONG_MONEY
*"----------------------------------------------------------------------
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 = i_money.
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 o_money INTO o_money.
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 o_money INTO o_money.
ENDIF.
*-输出‘整’字-------------------------------------
IF o_money = ' '.
CONCATENATE '整' o_money INTO o_money.
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 o_money INTO o_money.
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 o_money INTO o_money.
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 o_money INTO o_money.
v_flag0 = 0.
ENDIF.
IF v_index = 5 AND v_len > 5 AND v_len < 9 .
CONCATENATE '万' o_money INTO o_money.
ELSEIF v_index = 9 AND v_len > 9.
CONCATENATE '亿' o_money INTO o_money.
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 o_money FOR '圆'.
IF sy-subrc = 0.
v_n = sy-fdpos - 2.
IF v_n >= 0.
IF o_money+v_n(2) = v_s00.
v_len = strlen( o_money ).
CONCATENATE o_money(v_n) o_money+sy-fdpos INTO o_money.
ENDIF.
ENDIF.
ENDIF.
ENDFUNCTION.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(I_MONEY) TYPE BF_DMBTR
*" EXPORTING
*" REFERENCE(O_MONEY)
*" EXCEPTIONS
*" WRONG_MONEY
*"----------------------------------------------------------------------
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 = i_money.
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 o_money INTO o_money.
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 o_money INTO o_money.
ENDIF.
*-输出‘整’字-------------------------------------
IF o_money = ' '.
CONCATENATE '整' o_money INTO o_money.
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 o_money INTO o_money.
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 o_money INTO o_money.
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 o_money INTO o_money.
v_flag0 = 0.
ENDIF.
IF v_index = 5 AND v_len > 5 AND v_len < 9 .
CONCATENATE '万' o_money INTO o_money.
ELSEIF v_index = 9 AND v_len > 9.
CONCATENATE '亿' o_money INTO o_money.
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 o_money FOR '圆'.
IF sy-subrc = 0.
v_n = sy-fdpos - 2.
IF v_n >= 0.
IF o_money+v_n(2) = v_s00.
v_len = strlen( o_money ).
CONCATENATE o_money(v_n) o_money+sy-fdpos INTO o_money.
ENDIF.
ENDIF.
ENDIF.
ENDFUNCTION.