Hi, by suggestions of mattias, i post this code, as an example, or as a nice subroutine thata makes the translation of a number to letters, i hope be useful, or at least as an nice example 8)
P.D. it’s in spanish, but you can translate it.
DEFINE DATA
PARAMETER
01 NUMERO00 (N9.2)
01 REDEFINE NUMERO00
02 NUM01 (N1) 02 NUM02 (N1)
02 NUM03 (N1) 02 NUM04 (N1)
02 NUM05 (N1) 02 NUM06 (N1)
02 NUM07 (N1) 02 NUM08 (N1)
02 NUM09 (N1) 02 NUM10 (A2)
01 REDEFINE NUMERO00
02 NUMA1 (N1) 02 NUMA2 (N2)
02 NUMA3 (N1) 02 NUMA4 (N2)
02 NUMA5 (N1) 02 NUMA6 (N2)
02 NUMA7 (A2)
01 REDEFINE NUMERO00
02 NUMB1 (N1) 02 NUMB2 (N1)
02 NUMB3 (N1) 02 NUMB4 (N6)
02 NUMB5 (N2)
01 REDEFINE NUMERO00
02 NUMC1 (N9) 02 NUMC2 (N2)
01 NUMERO01 (A131)
01 REDEFINE NUMERO01
02 NUMERO02 (A54)
02 NUMERO03 (A77)
01 REDEFINE NUMERO01
02 NUMERO04 (A1/1:131)
LOCAL
01 TABLA01 (A6/1:9) INIT (V)
<‘UNO’,‘DOS’,‘TRES’,‘CUATRO’,‘CINCO’,‘SEIS’,‘SIETE’,‘OCHO’,‘NUEVE’>
01 TABLA02 (A7/10:20) INIT (V)
<‘DIEZ’,‘ONCE’,‘DOCE’,‘TRECE’,‘CATORCE’,‘QUINCE’, , , , ,‘VEINTE’>
01 TABLA03 (A9/2:9) INIT (V)
<‘VEINTI’,‘TREINTA’,‘CUARENTA’,‘CINCUENTA’,‘SESENTA’,‘SETENTA’,
‘OCHENTA’,‘NOVENTA’>
01 TABLA04 (A13/1:9) INIT (V)
<‘CIENTO’,‘DOSCIENTOS’,‘TRESCIENTOS’,‘CUATROCIENTOS’,‘QUINIENTOS’,
‘SEISCIENTOS’,‘SETECIENTOS’,‘OCHOCIENTOS’,
‘NOVECIENTOS’>
01 TABLA05 (A11/1:14) INIT (V)
<‘/100’,‘CON’,‘CON’,‘DIECI’,‘VEINTI’,‘Y’,‘CIEN’,‘MIL’,
‘MILLONES’,‘MILLONES’,‘MILLON’,‘MILLON’,‘CERO’,‘UNO’>
01 NUMERO05 (A131)
01 REDEFINE NUMERO05
02 NUMERO06 (A1/1:131)
01 LETRAS (A15)
01 I (N3)
01 J (N3)
01 CONT (N4)
01 CONT1 (N4)
01 LIMITE (N4)
01 NUMAC (N2)
01 NUMAD (N2)
01 NUMAE (N2)
01 NUMDEC (A6)
01 NUMC1-A (A11)
01 #ASTERISCOS (A20)
01 #CONT (N3)
01 #I (N3)
*
END-DEFINE
*
COMPRESS NUM10 TABLA05 (1) TO NUMERO01 LEAVING NO SPACE
IF NUMERO00 GE 1 AND NUMERO00 LE 1.99
COMPRESS TABLA05 (2) NUMERO01 TO NUMERO01
ELSE
COMPRESS TABLA05 (3) NUMERO01 TO NUMERO01
END-IF
*
IF NUMERO00 > 1.99
- … (9)
IF NUM09 > 0 AND NOT(NUMA6 GE 10 AND NUMA6 LE 15)
COMPRESS TABLA01 (NUM09) NUMERO01 TO NUMERO01
END-IF - … (9) (8)
IF NUMA6 GE 10 AND NUMA6 LE 15 OR NUMA6 = 20
COMPRESS TABLA02 (NUMA6) NUMERO01 TO NUMERO01
END-IF
MOVE NUMA6 TO NUMAC
MOVE NUM08 TO NUMAD
MOVE NUM09 TO NUMAE
PERFORM COMPLETA
RESET NUMAC NUMAD NUMAE - … (7)
IF NUM07 > 0
MOVE TABLA04 (NUM07) TO LETRAS
IF NUM07 = 1 AND NUMA6 = 0
MOVE TABLA05 (7) TO LETRAS
END-IF
COMPRESS LETRAS NUMERO01 TO NUMERO01
END-IF - … (6)
IF (NUM06 > 0 AND (NUM07 > 0 OR NUMA6 > 0)) OR
NUM05 > 0 OR NUM04 > 0 OR NUM06 > 0
IF NUM06 > 0
MOVE TABLA01 (NUM06) TO LETRAS
END-IF
IF ((NUM05 > 0 OR NUM04 > 0) AND NUM06 = 0)
OR (NUMA4 GE 10 AND NUMA4 LE 15) OR NUMA4 = 20
OR (NUMERO00 LE 1999.99)
RESET LETRAS
END-IF
COMPRESS LETRAS TABLA05 (8) NUMERO01 TO NUMERO01
END-IF - … (6) (5)
IF NUMA4 GE 10 AND NUMA4 LE 15 OR NUMA4 = 20
COMPRESS TABLA02 (NUMA4) NUMERO01 TO NUMERO01
END-IF - MOVE NUMA4 TO NUMAC
MOVE NUM05 TO NUMAD
MOVE NUM06 TO NUMAE
PERFORM COMPLETA
RESET NUMAC NUMAD NUMAE - … (4)
IF NUM04 > 0
MOVE TABLA04 (NUM04) TO LETRAS
IF NUM04 = 1 AND NUMA4 = 0
MOVE TABLA05 (7) TO LETRAS
END-IF
COMPRESS LETRAS NUMERO01 TO NUMERO01
END-IF - … (3)
IF NUM03 > 0 OR NUM02 > 0 OR NUM01 > 0
IF NUM03 > 0
MOVE TABLA01 (NUM03) TO LETRAS
END-IF
IF ((NUM02 > 0 OR NUM01 > 0) AND NUM03 = 0)
OR (NUMA2 GE 10 AND NUMA2 LE 15) OR NUMA2 = 20
RESET LETRAS
END-IF
IF (NUM03 > 1 OR NUM03 = 0 OR NUM02 > 0 OR NUM01 > 0) AND NUMB4 > 0
COMPRESS LETRAS TABLA05 (9) NUMERO01 TO NUMERO01
END-IF
IF (NUM03 > 1 OR NUM03 = 0 OR NUM02 > 0 OR NUM01 > 0) AND NUMB4 = 0
COMPRESS LETRAS TABLA05 (10) NUMERO01 TO NUMERO01
END-IF
IF NUM03 = 1 AND NUM02 = 0 AND NUM01 = 0 AND NUMA3 = 0
AND NUMA4 = 0 AND NUMA5 = 0 AND NUMA6 = 0
COMPRESS LETRAS TABLA05 (11) NUMERO01 TO NUMERO01
ELSE
IF NUM03 = 1 AND NUM02 = 0 AND NUM01 = 0
COMPRESS LETRAS TABLA05 (12) NUMERO01 TO NUMERO01
END-IF
END-IF
END-IF - … (2)
IF NUMA2 GE 10 AND NUMA2 LE 15 OR NUMA2 = 20
COMPRESS TABLA02 (NUMA2) NUMERO01 TO NUMERO01
END-IF
MOVE NUMA2 TO NUMAC
MOVE NUM02 TO NUMAD
MOVE NUM03 TO NUMAE
PERFORM COMPLETA
RESET NUMAC NUMAD NUMAE - … (1)
IF NUM01 > 0
MOVE TABLA04 (NUM01) TO LETRAS
IF NUM01 = 1 AND NUMA2 = 0
MOVE TABLA05 (7) TO LETRAS
END-IF
COMPRESS LETRAS NUMERO01 TO NUMERO01
END-IF
END-IF
*
IF NUMERO00 GE 0 AND NUMERO00 LE 0.99
COMPRESS TABLA05 (13) NUMERO01 TO NUMERO01
END-IF
IF NUMERO00 GE 1 AND NUMERO00 LE 1.99
COMPRESS TABLA05 (14) NUMERO01 TO NUMERO01
END-IF
*
FOR I 1 131
- ADD 1 TO CONT
IF NUMERO04 (I) = ’ ’ AND NUMERO04 (I + 1) = ’ ’
ESCAPE BOTTOM IMMEDIATE
END-IF
ADD 1 TO CONT
END-FOR
IF NUMERO03 NE ’ ’
MOVE 94 TO LIMITE
ELSE
MOVE 54 TO LIMITE
END-IF
RESET #CONT #ASTERISCOS
COMPUTE LIMITE = 90
COMPUTE #CONT = (LIMITE - CONT - 2) / 2
IF #CONT < 0 THEN
RESET numero01
ELSE
COMPUTE #CONT = 2
MOVE ALL ‘*’ TO #ASTERISCOS UNTIL #CONT
COMPRESS #ASTERISCOS numero01 #ASTERISCOS TO numero01
END-IF
*
DEFINE SUBROUTINE COMPLETA
IF NUMAC GE 16 AND NUMAC LE 19
COMPRESS TABLA05 (4) NUMERO01 TO NUMERO01 LEAVING NO SPACE
END-IF
IF NUMAC GT 20 AND NUMAC LE 29
COMPRESS TABLA05 (5) NUMERO01 TO NUMERO01 LEAVING NO SPACE
END-IF
IF NUMAD > 2
IF NUMAE > 0
MOVE TABLA05 (6) TO LETRAS
ELSE
RESET LETRAS
END-IF
IF NUMAD > 2
COMPRESS TABLA03 (NUMAD) LETRAS NUMERO01 TO NUMERO01
END-IF
END-IF
END-SUBROUTINE
*
END