*&---------------------------------------------------------------------*
*& Report Z_BARRY_CONV_AMOUNT *
*& *
*&---------------------------------------------------------------------*
*& 金额大写转换 *
*&---------------------------------------------------------------------*
REPORT Z_BARRY_CONV_AMOUNT .
TYPES: CUR6 TYPE P DECIMALS 6 ,
CUR2 TYPE P DECIMALS 2 .
DATA VA1 TYPE CUR2.
DATA STR(40) TYPE C .
VA1 = '232.23'.
PERFORM CONV_AMOUNT USING VA1
CHANGING STR.
WRITE STR.
*&--------------------------------------------------------------------*
*& Form conv_amount
*&--------------------------------------------------------------------*
FORM CONV_AMOUNT USING VALUE(F_SOURCE)
CHANGING VALUE(F_RESULT).
DATA: SCR(30) TYPE C, RES(60) TYPE C,FEN(2) TYPE C .
DATA: LEN TYPE I, C1 TYPE I, C2 TYPE I, C3 TYPE I, C4 TYPE I.
DATA: D1(1) TYPE C, D2(1) TYPE C, D3 TYPE I.
DATA: DIGIT(2) TYPE C, WEIGHT(2) TYPE C.
DATA: RULE1(20) TYPE C VALUE '零壹贰叁肆伍陆柒捌玖'.
DATA: RULE2(30) TYPE C VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万'.
SCR = F_SOURCE * 100.
CONDENSE SCR NO-GAPS.
IF SCR = '0'.
RES = '零元'.
ELSE.
LEN = STRLEN( SCR ).
C1 = 0.
D1 = '0'.
CLEAR RES.
DO LEN TIMES.
C1 = C1 + 1.
C2 = LEN - C1.
D2 = SCR+C2(1) .
IF D2 = '0'.
D3 = 0.
ELSE.
D3 = D2 * 2.
ENDIF.
DIGIT = RULE1+D3(2) .
C3 = ( C1 - 1 ) * 2.
WEIGHT = RULE2+C3(2) .
IF D2 = '0'.
IF C1 = 3.
DIGIT = ''.
ELSEIF C1 = 7.
DIGIT = ''.
IF LEN > 10 .
C4 = LEN - 10.
IF SCR+C4(4) = '0000'.
WEIGHT = ''.
ENDIF.
ENDIF.
ELSEIF C1 = 11.
DIGIT = ''.
ELSEIF D1 = '0'.
DIGIT = ''.
WEIGHT = ''.
ELSE.
WEIGHT = ''.
ENDIF.
ENDIF.
* CONCATENATE digit weight res INTO res. "汉字间是否加进空格
CONCATENATE DIGIT WEIGHT RES INTO RES SEPARATED BY SPACE.
D1 = D2.
ENDDO.
ENDIF.
LEN = STRLEN( RES ) - 2.
FEN = RES+LEN(2).
IF FEN <> '分' .
CONCATENATE RES ' 整' INTO F_RESULT.
ELSE.
F_RESULT = RES.
ENDIF.
ENDFORM. "conv_amount
*------------------------------------------------------------*
FOR UNICODE 系统:
REPORT z_barry_test NO STANDARD PAGE HEADING .
TYPES: CUR6 TYPE P DECIMALS 6 ,
CUR2 TYPE P DECIMALS 2 .
DATA VA1 TYPE CUR2.
DATA STR(40) TYPE C .
VA1 = '1000123.5'.
PERFORM CONV_AMOUNT USING VA1
CHANGING STR.
WRITE STR.
*&--------------------------------------------------------------------*
*& Form conv_amount
*&--------------------------------------------------------------------*
FORM CONV_AMOUNT USING VALUE(F_SOURCE)
CHANGING VALUE(F_RESULT).
DATA: SCR(30) TYPE C, RES(60) TYPE C,FEN(2) TYPE C .
DATA: LEN TYPE I, C1 TYPE I, C2 TYPE I, C3 TYPE I, C4 TYPE I.
DATA: D1(1) TYPE C, D2(1) TYPE C, D3 TYPE I.
DATA: DIGIT(2) TYPE C, WEIGHT(2) TYPE C.
DATA: RULE1(20) TYPE C VALUE '零壹贰叁肆伍陆柒捌玖'.
DATA: RULE2(30) TYPE C VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万'.
SCR = F_SOURCE * 100.
CONDENSE SCR NO-GAPS.
IF SCR = '0'.
RES = '零元'.
ELSE.
LEN = STRLEN( SCR ).
C1 = 0.
D1 = '0'.
CLEAR RES.
DO LEN TIMES.
C1 = C1 + 1.
C2 = LEN - C1.
D2 = SCR+C2(1) .
IF D2 = '0'.
D3 = 0.
ELSE.
D3 = D2.
ENDIF.
DIGIT = RULE1+D3(1) .
C3 = ( C1 - 1 ) .
WEIGHT = RULE2+C3(1) .
IF D2 = '0'.
IF C1 = 3.
DIGIT = ''.
ELSEIF C1 = 7.
DIGIT = ''.
IF LEN > 10 .
C4 = LEN - 10.
IF SCR+C4(4) = '0000'.
WEIGHT = ''.
ENDIF.
ENDIF.
ELSEIF C1 = 11.
DIGIT = ''.
ELSEIF D1 = '0'.
DIGIT = ''.
WEIGHT = ''.
ELSE.
WEIGHT = ''.
ENDIF.
ENDIF.
CONCATENATE DIGIT WEIGHT RES INTO RES .
D1 = D2.
ENDDO.
ENDIF.
LEN = STRLEN( RES ) - 1.
FEN = RES+LEN(1).
IF FEN <> '分' .
CONCATENATE RES '整' INTO F_RESULT.
ELSE.
F_RESULT = RES.
ENDIF.
ENDFORM. "conv_amount
***外币转换:
FUNCTION YLMM_SPELL_AMOUNT_EN.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(INPUT_AMOUNT) DEFAULT 0
*" EXPORTING
*" REFERENCE(OUTPUT_WORD) TYPE SPELL-WORD
*" EXCEPTIONS
*" ERROR_INPUT_FORMAT
*"----------------------------------------------------------------------
DATA : TEXT1(16) ,TEXT2(2) .
DATA : AMOUNT(16) TYPE P .
DATA : SPELL TYPE SPELL.
IF NOT INPUT_AMOUNT CO '0123456789. '.
RAISE ERROR_INPUT_FORMAT.
ENDIF.
SPLIT INPUT_AMOUNT AT '.' INTO TEXT1 TEXT2.
IF TEXT2 < 10 AND TEXT2+0(1) = '0'.
WRITE TEXT2 TO TEXT2 NO-GAP NO-ZERO.
CONDENSE TEXT2.
ELSEIF TEXT2 < 10 AND TEXT2+0(1) <> '0'.
TEXT2 = TEXT2 * 10.
ENDIF.
AMOUNT = TEXT1 .
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = AMOUNT
LANGUAGE = 'E'
IMPORTING
IN_WORDS = SPELL
EXCEPTIONS
NOT_FOUND = 01
TOO_LARGE = 02.
AMOUNT = TEXT2.
IF AMOUNT = 0 .
CONCATENATE SPELL-WORD ' Dollars Only' INTO OUTPUT_WORD.
ELSE.
CONCATENATE SPELL-WORD ' Dollars AND' INTO OUTPUT_WORD .
IF 1 = 1.
CONCATENATE OUTPUT_WORD TEXT2 'Cents Only' INTO OUTPUT_WORD
SEPARATED BY SPACE.
ELSE.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = AMOUNT
LANGUAGE = 'E'
IMPORTING
IN_WORDS = SPELL
EXCEPTIONS
NOT_FOUND = 01
TOO_LARGE = 02.
CONCATENATE OUTPUT_WORD SPELL-WORD 'Cents Only' INTO OUTPUT_WORD
SEPARATED BY SPACE.
ENDIF.
ENDIF.
ENDFUNCTION.
***日期大写
阅读(8630) | 评论(2) | 转发(0) |