Progress - rutina cantidad numero a letras

 
Vista:

rutina cantidad numero a letras

Publicado por REHEBA (17 intervenciones) el 08/08/2014 04:36:28
Hola tendrán algún ejemplo para convertir una cifra en palabras desde PROGRSS. ejemplo 1,125,345.33 = un millón ciento veinticinco mil trescientos cuarenta y cinco /.33 gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Marcelo

rutina cantidad numero a letras

Publicado por Marcelo (8 intervenciones) el 13/08/2014 12:42:20
hola, buen dia.
te envio la rutina que utilizo para convertir de numeros a letras, espero te sirva.
saludos

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/**************************************/
/* letras.p */
 
 
def shared var monto as de format "zzz,zzz,zz9.99" decimals 2.
def shared var letras as c format "x(200)".
def var ente as i.
def var cent as i.
def var can as i.
def var aux as i.
def var mil as lo.
def var lar as i.
def var car as c format "x(20)".
def var let as c format "x".
def var num as i.
def var centena as c format "x(13)" extent 10 initial
      ["CIENTO",
       "DOSCIENTOS",
       "TRESCIENTOS",
       "CUATROCIENTOS",
       "QUINIENTOS",
       "SEISCIENTOS",
       "SETECIENTOS",
       "OCHOCIENTOS",
       "NOVECIENTOS"].
def var decena as c format "x(9)" extent 10 initial
      ["DIEZ",
       "VEINTE",
       "TREINTA",
       "CUARENTA",
       "CINCUENTA",
       "SESENTA",
       "SETENTA",
       "OCHENTA",
       "NOVENTA"].
def var decena2 as c format "x(9)" extent 10 initial
      ["DIEZ",
       "VEINTI",
       "TREINTA Y ",
       "CUARENTA Y ",
       "CINCUENTA Y ",
       "SESENTA Y ",
       "SETENTA Y ",
       "OCHENTA Y ",
       "NOVENTA Y "].
def var unidad as c format "x(8)" extent 10 initial
      ["UNO",
       "DOS",
       "TRES",
       "CUATRO",
       "CINCO",
       "SEIS",
       "SIETE",
       "OCHO",
       "NUEVE"].
def var raro as c format "x(10)" extent 10 initial
      ["DIEZ",
       "ONCE",
       "DOCE",
       "TRECE",
       "CATORCE",
       "QUINCE",
       "DIECISEIS",
       "DIECISIETE",
       "DIECIOCHO",
       "DIECINUEVE"].
letras="".
if monto=0 then return.
ente=truncate(monto,0).
cent=(monto - ente) * 100.
car=string(ente). can=length(car). lar=can. mil=yes.
repeat while can>0:
  can=length(car). let=substring(car,1,1).
  car=substring(car,2,(can - 1)).
  num=int(let).
  if can=9 then do:
    if num<>0 then do:
      if num=1 and substring(car,1,1)="0" and substring(car,2,1)="0" then
      letras=letras + "CIEN ".
      else
      letras=letras + centena[num] + " ".
    end.
  end.
  else if can=8 then do:
    if num<>0 then do:
    if num=1 then do:
      let=string(car,"x"). aux=int(let).
      letras=letras + raro[aux + 1] + " MILLONES ".
      car=substring(car,2,(can - 1)).
    end.
    else do:
      if substring(car,1,1)="0" then
      letras=letras + decena[num] + " ".
      else letras=letras + decena2[num].
    end.
    end.
  end.
  else if can=7 then do:
    if substring(car,1,1)="0" and substring(car,2,1)="0" and
    substring(car,3,1)="0" then mil=no.
    if num<>0 then do:
      if num=1 and substring(car,1,1)="0" then do:
	letras=letras + "UN ".
	if lar=7 then do: letras=letras + "MILLON ". next. end.
      end.
      else
      if num=1 then letras=letras + "UN ".
      else letras=letras + unidad[num] + " ".
    end.
    /*if num=1 then letras=letras + "MILLON ".
    else*/ letras=letras + "MILLONES ".
  end.
  if can=6 then do:
    if num<>0 then do:
      if num=1 and substring(car,1,1)="0" and substring(car,2,1)="0" then
      letras=letras + "CIEN ".
      else
      letras=letras + centena[num] + " ".
    end.
  end.
  else if can=5 then do:
    if num<>0 then do:
    if num=1 then do:
      let=string(car,"x"). aux=int(let).
      letras=letras + raro[aux + 1] + " MIL ".
      car=substring(car,2,(can - 1)).
    end.
    else do:
      if substring(car,1,1)="0" then
      letras=letras + decena[num] + " ".
      else letras=letras + decena2[num].
    end.
    end.
  end.
  else if can=4 then do:
    if num<>0 then do:
      if num=1 then do:
	letras=letras + "UN ".
      end.
      else
      letras=letras + unidad[num] + " ".
    end.
    if mil then letras=letras + "MIL ".
  end.
  if can=3 then do:
    if num<>0 then do:
      if num=1 and substring(car,1,1)="0" and substring(car,2,1)="0" then
      letras=letras + "CIEN ".
      else
      letras=letras + centena[num] + " ".
    end.
  end.
  else if can=2 then do:
    if num<>0 then do:
    if num=1 then do:
      let=string(car,"x"). aux=int(let).
      letras=letras + raro[aux + 1] + " ".
      car=substring(car,2,(can - 1)).
    end.
    else do:
      if substring(car,1,1)="0" then
      letras=letras + decena[num] + " ".
      else letras=letras + decena2[num].
    end.
    end.
  end.
  else if can=1 then do:
    if num<>0 then do:
      if num=1 and lar=1 then do:
	letras=letras + "UNO ".
	if lar=7 then do: letras=letras. next. end.
      end.
      else
      letras=letras + unidad[num].
    end.
  end.
end.
/*if ente=1 then letras=letras + "PESO".
else if ente<>0 then letras=letras + "PESOS".*/
if ente<>0 and substring(letras,length(letras),1)=" " then
letras=substring(letras,1,length(letras) - 1).
if cent=0 then do: letras=letras + ".". return. end.
if ente<>0 then letras=letras + " CON ".
car=string(cent). can=length(car). lar=can.
repeat while can>0:
  can=length(car). let=substring(car,1,1).
  car=substring(car,2,(can - 1)).
  num=int(let).
  if can=2 then do:
    if num<>0 then do:
    if num=1 then do:
      let=string(car,"x"). aux=int(let).
      letras=letras + raro[aux + 1] + " ".
      car=substring(car,2,(can - 1)).
    end.
    else do:
      if substring(car,1,1)="0" then
      letras=letras + decena[num] + " ".
      else letras=letras + decena2[num].
    end.
    end.
  end.
  else if can=1 then do:
    if num<>0 then do:
      if num=1 and lar=1 then do:
	letras=letras + "UN ".
	if lar=7 then do: letras=letras. next. end.
      end.
      else
      letras=letras + unidad[num] + " ".
    end.
  end.
end.
if cent=1 then letras=letras + "CENTAVO.". else letras=letras + "CENTAVOS.".
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

rutina cantidad numero a letras

Publicado por Rene (17 intervenciones) el 27/08/2014 20:57:34
Ok si me sirvió muchas gracias saludos BYE
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar