金額大寫轉換(摘)
*&---------------------------------------------------------------------*
*& Report Z_BARRY_CONV_AMOUNT *
*& *
*&---------------------------------------------------------------------*
*& 金額大寫轉換 *
*&---------------------------------------------------------------------*
*& 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 .
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.
CHANGING STR.
WRITE STR.
*&--------------------------------------------------------------------*
*& Form conv_amount
*&--------------------------------------------------------------------*
FORM. CONV_AMOUNT USING VALUE(F_SOURCE)
CHANGING VALUE(F_RESULT).
*&--------------------------------------------------------------------*
*& 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 '分角元拾佰仟萬拾佰仟億拾佰仟萬'.
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
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
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
*"----------------------------------------------------------------------
*"----------------------------------------------------------------------
*"*"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.
DATA : AMOUNT(16) TYPE P .
DATA : SPELL TYPE SPELL.
IF NOT INPUT_AMOUNT CO '0123456789. '.
RAISE ERROR_INPUT_FORMAT.
ENDIF.
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.
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.
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.
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.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16794144/viewspace-623586/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 小寫金額轉換為大寫
- 將金錢數額轉換為大寫
- Python 轉換金額數字大寫為數字小寫Python
- 小寫數字金額轉大寫
- 數字金額轉中文繁體大寫
- 用js實現小寫金額轉大寫的方法JS
- jquery金額數字轉為大寫數字jQuery
- JavaScript 人民幣金額格式轉換JavaScript
- 匹配大寫金額正規表示式
- excel大寫字母轉換Excel
- 【踩坑系列】使用long型別處理金額,科學計數法導致金額轉大寫異常型別
- Python數字轉換中文大寫Python
- .NET神器:輕鬆實現數字轉大寫金額的秘籍與示例程式碼
- 字串-大小寫轉換字串
- 試題 演算法提高 小寫轉換為大寫 C++演算法C++
- 恆大涉案金額達到此次金螳螂披露的合計涉案金額的95.57%
- JavaScript字母大小寫轉換JavaScript
- JavaScript字串大小寫轉換JavaScript字串
- 自寫Json轉換工具JSON
- 寫一個格式化金額的方法
- 一文搞定Python大小寫轉換,首字母大寫,去除特殊字元Python字元
- 1.金額數字轉字元型別字元型別
- js 小寫轉換,取字尾JS
- 使用正則 轉換大小寫
- 將字串轉換成大寫 2020.12.28字串
- Web 頁面怎麼加貨幣符號和大寫轉換Web符號
- 字串中大小寫轉換輸出字串
- CSS text-transform字元大小寫轉換CSSORM字元
- Leecode709. 轉換成小寫字母
- 在 Linux 命令列中轉換大小寫Linux命令列
- Python中怎麼轉換字串大小寫Python字串
- fastjson轉換json時,碰到的那些首字母大小寫轉換的坑!ASTJSON
- HarmonyOS Next 金鑰轉換技巧:提升加解密靈活性解密
- C#和JAVA的RSA金鑰、公鑰轉換C#Java
- 鍵盤大寫字母按哪個鍵 轉換英文字母大小寫是哪個鍵
- 浙江、深圳試點大額現金管理 大額取現至少提前1天預約MRV
- MySQL-資料記錄大小寫轉換MySql
- 批次目錄檔名大小寫轉換器
- 字串大小寫轉換和字串的比較字串