TYPES: BEGIN OF ty_strno,
innum(1) TYPE c,
prono(6) TYPE c,
END OF ty_strno.
DATA: gt_strno TYPE TABLE OF ty_strno WITH HEADER LINE.
DATA: gs_strno TYPE ty_strno.
FUNCTION zfm_fi_spell_amount_vn.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” VALUE(IV_PDEC) TYPE ZDE_PIN_DAMNT
*” VALUE(IV_CURR) TYPE WAERS
*” EXPORTING
*” REFERENCE(EV_OUTSTR) TYPE CHAR255
*”———————————————————————-
DATA: gv_number(18) TYPE c,
gv_numtmp(22) TYPE c,
gv_numdec(2) TYPE c,
gv_3digit(3) TYPE c,
gv_no(9) TYPE c,
gv_more(1) TYPE c,
gv_slen TYPE i.
DATA: gv_string(100) TYPE c,
gv_prono(255) TYPE c.
IF iv_curr = ‘VND’.
iv_pdec = iv_pdec * 100.
ELSE.
ENDIF.
PERFORM fo_prepare_number.
gv_numtmp = iv_pdec.
gv_numdec = gv_numtmp+19(2).
SHIFT gv_numtmp BY 4 PLACES RIGHT.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
input = gv_numtmp
IMPORTING
output = gv_numtmp.
SHIFT gv_numtmp BY 4 PLACES LEFT.
gv_number = gv_numtmp.
DO.
CLEAR: gv_more.
gv_no = gv_number+9(9).
SHIFT gv_number BY 9 PLACES RIGHT.
IF gv_number > 0.
gv_more = ‘X’.
ENDIF.
PERFORM fo_read_9digit USING gv_no gv_string gv_more.
CONDENSE gv_string.
IF gv_more = ‘X’.
CONCATENATE ‘TỶ’ gv_string gv_prono
INTO gv_prono SEPARATED BY space.
ELSE.
CONCATENATE gv_string gv_prono
INTO gv_prono SEPARATED BY space.
ENDIF.
IF gv_more <> ‘X’.
EXIT.
ENDIF.
ENDDO.
CONDENSE gv_prono.
IF gv_prono IS INITIAL.
gv_prono = ‘KHÔNG’.
ENDIF.
IF iv_curr <> ‘VND’.
TRANSLATE gv_prono TO LOWER CASE.
TRANSLATE gv_prono+0(1) TO UPPER CASE.
CONCATENATE gv_prono iv_curr
INTO gv_prono SEPARATED BY space.
ELSE.
CONCATENATE gv_prono ‘ĐỒNG CHẴN’
INTO gv_prono SEPARATED BY space.
TRANSLATE gv_prono TO LOWER CASE.
TRANSLATE gv_prono+0(1) TO UPPER CASE.
ENDIF.
CONDENSE gv_prono.
IF gv_numdec = ’00’.
* TRANSLATE gv_prono TO LOWER CASE.
* TRANSLATE gv_prono+0(1) TO UPPER CASE.
ev_outstr = gv_prono.
RETURN.
ENDIF.
* IF iv_curr = ‘USD’
* OR iv_curr = ‘SGC’.
IF iv_curr <> ‘VND’.
CLEAR: gv_string.
gv_3digit = ‘000’.
gv_3digit+1(2) = gv_numdec.
PERFORM fo_read_3digit USING gv_3digit gv_string ” ”.
TRANSLATE gv_string TO LOWER CASE.
CONCATENATE gv_string ‘CENTS’
INTO gv_string
SEPARATED BY space.
CONCATENATE gv_prono gv_string
INTO gv_prono
SEPARATED BY space.
CONDENSE gv_prono.
ENDIF.
* TRANSLATE gv_prono TO LOWER CASE.
* TRANSLATE gv_prono+0(1) TO UPPER CASE.
ev_outstr = gv_prono.
ENDFUNCTION.
*&———————————————————————*
*& Form FO_PREPARE_NUMBER
*&———————————————————————*
FORM fo_prepare_number .
gs_strno–innum = ‘0’.
gs_strno–prono = ‘KHÔNG’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘1’.
gs_strno–prono = ‘MỘT’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘2’.
gs_strno–prono = ‘HAI’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘3’.
gs_strno–prono = ‘BA’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘4’.
gs_strno–prono = ‘BỐN’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘5’.
gs_strno–prono = ‘NĂM’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘6’.
gs_strno–prono = ‘SÁU’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘7’.
gs_strno–prono = ‘BẢY’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘8’.
gs_strno–prono = ‘TÁM’.
APPEND gs_strno TO gt_strno.
gs_strno–innum = ‘9’.
gs_strno–prono = ‘CHÍN’.
APPEND gs_strno TO gt_strno.
ENDFORM. ” FO_PREPARE_NUMBER
*&———————————————————————*
*& Form FO_READ_3DIGIT
*&———————————————————————*
FORM fo_read_3digit USING p_no
p_string
p_more
p_unit.
DATA: lv_str(100) TYPE c.
IF p_no = ‘000’.
p_string = ”.
RETURN.
ENDIF.
IF p_no+0(2) = ’00’.
READ TABLE gt_strno INTO gs_strno WITH KEY innum = p_no+2(1).
IF p_unit = ‘X’ AND p_more = ‘X’.
CONCATENATE ‘LẺ’ gs_strno–prono
INTO p_string SEPARATED BY space.
RETURN.
ELSE.
p_string = gs_strno–prono.
RETURN.
ENDIF.
ENDIF.
IF p_no+1(2) = ’00’.
READ TABLE gt_strno INTO gs_strno WITH KEY innum = p_no+0(1).
CONCATENATE gs_strno–prono ‘TRĂM’
INTO p_string SEPARATED BY space.
RETURN.
ENDIF.
IF p_no+0(1) = ‘0’ AND p_more = space.
ELSE.
READ TABLE gt_strno INTO gs_strno WITH KEY innum = p_no+0(1).
CONCATENATE gs_strno–prono ‘TRĂM’
INTO p_string SEPARATED BY space.
ENDIF.
IF p_no+1(1) = ‘0’.
CONCATENATE p_string ‘LẺ’
INTO p_string SEPARATED BY space.
ELSEIF p_no+1(1) = ‘1’.
CONCATENATE p_string ‘MƯỜI’
INTO p_string SEPARATED BY space.
ELSE.
READ TABLE gt_strno INTO gs_strno WITH KEY innum = p_no+1(1).
CONCATENATE p_string gs_strno–prono ‘MƯƠI’
INTO p_string SEPARATED BY space.
ENDIF.
IF p_no+2(1) <> ‘0’.
IF p_no+1(1) <> ‘0’
AND p_no+1(1) <> ‘1’
AND p_no+2(1) = ‘1’.
gs_strno–prono = ‘MỐT’.
ELSEIF p_no+1(1) <> ‘0’ AND p_no+2(1) = ‘5’.
gs_strno–prono = ‘LĂM’.
ELSE.
READ TABLE gt_strno INTO gs_strno WITH KEY innum = p_no+2(1).
ENDIF.
CONCATENATE p_string gs_strno–prono
INTO p_string SEPARATED BY space.
ENDIF.
ENDFORM. ” FO_READ_3DIGIT
*&———————————————————————*
*& Form FO_READ_9DIGIT
*&———————————————————————*
FORM fo_read_9digit USING p_no
p_string
p_more.
DATA: lv_no(3) TYPE c,
lv_string(100) TYPE c,
lv_more(1) TYPE c,
lv_unit(1) TYPE c.
lv_no = p_no+6(3).
lv_unit = ‘X’.
SHIFT p_no BY 3 PLACES RIGHT.
IF p_no > 0 OR p_more = ‘X’.
lv_more = ‘X’.
ENDIF.
CLEAR lv_string.
PERFORM fo_read_3digit USING lv_no lv_string lv_more lv_unit.
p_string = lv_string.
lv_no = p_no+6(3).
CLEAR: lv_more, lv_unit.
SHIFT p_no BY 3 PLACES RIGHT.
IF p_no > 0 OR p_more = ‘X’.
lv_more = ‘X’.
ENDIF.
CLEAR lv_string.
PERFORM fo_read_3digit USING lv_no lv_string lv_more lv_unit.
IF lv_string IS NOT INITIAL.
CONCATENATE lv_string ‘NGÀN’ p_string
INTO p_string SEPARATED BY space.
ENDIF.
lv_no = p_no+6(3).
lv_more = p_more.
CLEAR lv_string.
PERFORM fo_read_3digit USING lv_no lv_string lv_more lv_unit.
IF lv_string IS NOT INITIAL.
CONCATENATE lv_string ‘TRIỆU’ p_string
INTO p_string SEPARATED BY space.
ENDIF.
ENDFORM. ” FO_READ_9DIGIT