FUNCTION Z_DIGITAL_LOWER_TO_UPPER.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(DIGITALIN) TYPE C
*" EXPORTING
*" VALUE(DIGITALOUT) TYPE C
*"----------------------------------------------------------------------
IF digitalin = '0'.
digitalout = '零'.
ELSEIF digitalin = '1'.
digitalout = '壹'.
ELSEIF digitalin = '2'.
digitalout = '贰'.
ELSEIF digitalin = '3'.
digitalout = '叁'.
ELSEIF digitalin = '4'.
digitalout = '肆'.
ELSEIF digitalin = '5'.
digitalout = '伍'.
ELSEIF digitalin = '6'.
digitalout = '陆'.
ELSEIF digitalin = '7'.
digitalout = '柒'.
ELSEIF digitalin = '8'.
digitalout = '捌'.
ELSEIF digitalin = '9'.
digitalout = '玖'.
ELSE.
digitalout = '×'.
ENDIF.
ENDFUNCTION.
FUNCTION Z_MONEY_LOWER_TO_UPPER.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(MONEYIN) TYPE CRMT_GROSS_VALUE_CUM
*" EXPORTING
*" VALUE(MONEYOUT) TYPE C
*"----------------------------------------------------------------------
DATA: ipos TYPE I,
iwan TYPE I,
imod TYPE I,
pin TYPE P DECIMALS 2,
strint TYPE C LENGTH 10,
strdec TYPE C LENGTH 3,
strintt TYPE C,
strintd TYPE C,
strintu TYPE C LENGTH 40,
strdect TYPE C,
strdecd TYPE C,
strdecu TYPE C LENGTH 4.
pin = MONEYIN.
IF pin eq 0.
ipos = 0.
ELSE.
ipos = FLOOR( LOG10( pin ) ) + 1. "计算数值pin的整数位数。
ENDIF.
*write / ipos.
*计算小数部分
pin = pin * 100. "将数值的百分位变为个位,便于处理。
strdect = pin - pin DIV 10 * 10. "获取数值的百分位,也就是分。
IF strdect NE '0'. "如果值为0,则不显示该值,直接跳过。
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER' "调用数值小写转大写的函数,获得大写的数字。
EXPORTING
DIGITALIN = strdect
IMPORTING
DIGITALOUT = strdecd.
CONCATENATE strdecd '分' INTO strdecu. "生成金额的“分”。
ENDIF.
pin = pin DIV 10. "将十分位变为个位。
strdect = pin - pin DIV 10 * 10. "获取数值的十分位,也就是角。
IF strdect EQ '0' AND strdecu EQ ''. "如果角为0,分也为0,则金额的小数部分就没有。
strdecu = ''.
ELSEIF strdect EQ '0' AND strdecu NE ''. "如果角为0,分不为0,则角位只写“零”不写“角”。
CONCATENATE '零' strdecu INTO strdecu.
ELSE. "如果角不为0,则直接与前面生成的分进行拼接。
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER' "调用数值小写转大写的函数。
EXPORTING
DIGITALIN = strdect
IMPORTING
DIGITALOUT = strdecd.
CONCATENATE strdecd '角' strdecu INTO strdecu. "生成金额的“角”和“分”
ENDIF.
pin = pin DIV 10. "恢复原来的整数位。
iwan = 0. "万位标记,四个数值位为一“万”,从个位开始,所以iwan的初值为0。
*计算整数部分
DO ipos TIMES.
strintt = pin - pin DIV 10 * 10.
imod = iwan MOD 4.
IF imod EQ 0.
IF iwan = 0.
IF strintt NE '0'.
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER'
EXPORTING
DIGITALIN = strintt
IMPORTING
DIGITALOUT = strintd.
strintu = strintd.
ENDIF.
ELSEIF iwan = 4.
IF strintt NE '0'.
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER'
EXPORTING
DIGITALIN = strintt
IMPORTING
DIGITALOUT = strintd.
ELSE.
strintd = ''.
ENDIF.
CONCATENATE strintd '万' strintu INTO strintu.
ELSEIF iwan = 8.
IF strintt NE '0'.
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER'
EXPORTING
DIGITALIN = strintt
IMPORTING
DIGITALOUT = strintd.
ELSE.
strintd = ''.
ENDIF.
CONCATENATE strintd '亿' strintu INTO strintu.
ENDIF.
ENDIF.
IF imod EQ 1.
IF strintt NE '0'.
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER'
EXPORTING
DIGITALIN = strintt
IMPORTING
DIGITALOUT = strintd.
CONCATENATE strintd '拾' strintu INTO strintu.
ELSEIF strintd NE '零'.
CONCATENATE '零' strintu INTO strintu.
ENDIF.
ENDIF.
IF imod EQ 2.
IF strintt NE '0'.
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER'
EXPORTING
DIGITALIN = strintt
IMPORTING
DIGITALOUT = strintd.
CONCATENATE strintd '佰' strintu INTO strintu.
ELSEIF strintd NE '零'.
CONCATENATE '零' strintu INTO strintu.
ENDIF.
ENDIF.
IF imod EQ 3.
IF strintt NE '0'.
CALL FUNCTION 'Z_DIGITAL_LOWER_TO_UPPER'
EXPORTING
DIGITALIN = strintt
IMPORTING
DIGITALOUT = strintd.
CONCATENATE strintd '仟' strintu INTO strintu.
ELSEIF strintd NE '零'.
CONCATENATE '零' strintu INTO strintu.
ENDIF.
ENDIF.
pin = pin DIV 10.
iwan = iwan + 1.
* write: / iwan, strintt, strintu, imod.
ENDDO.
*连接整数位和小数位。
CONCATENATE strintu '元' strdecu INTO MONEYOUT.
*把“零亿”、“零万”、“零元”都替换掉。
REPLACE ALL OCCURRENCES OF '零零' in monEYOUT with '零' .
REPLACE ALL OCCURRENCES OF '零零' in monEYOUT with '零' .
REPLACE ALL OCCURRENCES OF '零亿' in monEYOUT with '亿' .
REPLACE ALL OCCURRENCES OF '零万' in monEYOUT with '万' .
REPLACE ALL OCCURRENCES OF '零元' in monEYOUT with '元' .
IF ipos eq 0.
MONEYOUT = '零元'.
ENDIF.
ENDFUNCTION.
阅读(3315) | 评论(0) | 转发(0) |