将金额转换成大写中文

form chinesemoney using val changing dxstr.
DATA: ZS(15).
DATA: XS(15).
DATA: STR(30).
DATA: LEN TYPE I value 0.
DATA: CIS TYPE I value 0.
DATA: SS(2).
DATA: RR(1).
DATA: STRR(15).
DATA: change(30) TYPE C value
'1壹2贰3叁4肆5伍6陆7柒8捌9玖0零'.

*data dxstr(80).
CLEAR DXSTR.
MOVE val TO STR.
SHIFT STR LEFT DELETING LEADING SPACE.
SHIFT STR LEFT DELETING LEADING '0'.
SPLIT STR AT '.' INTO ZS XS.

LEN = STRLEN( ZS ).
CLEAR STRR.
CIS = LEN - 1.
DO LEN TIMES.
MOVE ZS+CIS(1) TO RR.
CONCATENATE STRR RR INTO STRR.
CIS = CIS - 1.
ENDDO.

CIS = 0.
DO LEN TIMES.
MOVE STRR+CIS(1) TO SS.
TRANSLATE SS USING change.

CASE CIS.
WHEN 0. IF SS = '零'.
CONCATENATE '元' DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '元' DXSTR INTO DXSTR.
ENDIF.
WHEN 1. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '拾' DXSTR INTO DXSTR.
ENDIF.
WHEN 2. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '佰' DXSTR INTO DXSTR.
ENDIF.
WHEN 3. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '仟' DXSTR INTO DXSTR.
ENDIF.
WHEN 4. IF SS = '零'.
CONCATENATE '万' DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '万' DXSTR INTO DXSTR.
ENDIF.
WHEN 5.
IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '拾' DXSTR INTO DXSTR.
ENDIF.
WHEN 6. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '佰' DXSTR INTO DXSTR.
ENDIF.
WHEN 7. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '仟' DXSTR INTO DXSTR.
ENDIF.
WHEN 8. IF SS = '零'.
CONCATENATE '亿' DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '亿' DXSTR INTO DXSTR.
ENDIF.
WHEN 9. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '拾' DXSTR INTO DXSTR.
ENDIF.
WHEN 10. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '百' DXSTR INTO DXSTR.
ENDIF.
WHEN 11. IF SS = '零'.
CONCATENATE SS DXSTR INTO DXSTR.
ELSE.
CONCATENATE SS '仟' DXSTR INTO DXSTR.
ENDIF.
ENDCASE.
CIS = CIS + 1.
ENDDO.
CLEAR SS.
IF XS <> '00'.
MOVE XS+0(1) TO SS. TRANSLATE SS USING change.
IF SS <> '零'.
CONCATENATE DXSTR SS '角' INTO DXSTR.
ENDIF.
MOVE XS+1(1) TO SS. TRANSLATE SS USING change.
IF SS <> '零'.
CONCATENATE DXSTR SS '分' INTO DXSTR.
ENDIF.
ELSE.
CONCATENATE DXSTR '整' INTO DXSTR.
ENDIF.

REPLACE '零零零' WITH '零' INTO DXSTR.
REPLACE '零零零' WITH '零' INTO DXSTR.
REPLACE '零零零' WITH '零' INTO DXSTR.
REPLACE '零零' WITH '零' INTO DXSTR.
REPLACE '零零' WITH '零' INTO DXSTR.
REPLACE '零零' WITH '零' INTO DXSTR.
REPLACE '零万' WITH '万' INTO DXSTR.
REPLACE '零元' WITH '元' INTO DXSTR.
REPLACE '零亿' WITH '亿' INTO DXSTR.
REPLACE '亿万' WITH '亿' INTO DXSTR.
CONDENSE DXSTR NO-GAPS.

IF DXSTR = '整'.
DXSTR = ''.
ENDIF.

endform.

你可能感兴趣的:(中文)