-
Notifications
You must be signed in to change notification settings - Fork 0
/
BANK5.cbl
322 lines (250 loc) · 10.6 KB
/
BANK5.cbl
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
IDENTIFICATION DIVISION.
PROGRAM-ID. BANK5.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
CRT STATUS IS KEYBOARD-STATUS.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OPTIONAL F-MOVIMIENTOS ASSIGN TO DISK
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS MOV-NUM
FILE STATUS IS FSM.
DATA DIVISION.
FILE SECTION.
FD F-MOVIMIENTOS
LABEL RECORD STANDARD
VALUE OF FILE-ID IS "../data/movimientos.ubd".
01 MOVIMIENTO-REG.
02 MOV-NUM PIC 9(35).
02 MOV-TARJETA PIC 9(16).
02 MOV-ANO PIC 9(4).
02 MOV-MES PIC 9(2).
02 MOV-DIA PIC 9(2).
02 MOV-HOR PIC 9(2).
02 MOV-MIN PIC 9(2).
02 MOV-SEG PIC 9(2).
02 MOV-IMPORTE-ENT PIC S9(7).
02 MOV-IMPORTE-DEC PIC 9(2).
02 MOV-CONCEPTO PIC X(35).
02 MOV-SALDOPOS-ENT PIC S9(9).
02 MOV-SALDOPOS-DEC PIC 9(2).
WORKING-STORAGE SECTION.
77 FSM PIC X(2).
78 BLACK VALUE 0.
78 BLUE VALUE 1.
78 GREEN VALUE 2.
78 CYAN VALUE 3.
78 RED VALUE 4.
78 MAGENTA VALUE 5.
78 YELLOW VALUE 6.
78 WHITE VALUE 7.
01 CAMPOS-FECHA.
05 FECHA.
10 ANO PIC 9(4).
10 MES PIC 9(2).
10 DIA PIC 9(2).
05 HORA.
10 HORAS PIC 9(2).
10 MINUTOS PIC 9(2).
10 SEGUNDOS PIC 9(2).
10 MILISEGUNDOS PIC 9(2).
05 DIF-GMT PIC S9(4).
01 KEYBOARD-STATUS PIC 9(4).
88 ENTER-PRESSED VALUE 0.
88 PGUP-PRESSED VALUE 2001.
88 PGDN-PRESSED VALUE 2002.
88 UP-ARROW-PRESSED VALUE 2003.
88 DOWN-ARROW-PRESSED VALUE 2004.
88 ESC-PRESSED VALUE 2005.
77 LAST-USER-MOV-NUM PIC 9(35).
77 LAST-MOV-NUM PIC 9(35).
77 EURENT-USUARIO PIC 9(7).
77 EURDEC-USUARIO PIC 9(2) VALUE 0.
77 EUR10 PIC 9(3).
77 EUR20 PIC 9(3).
77 EUR50 PIC 9(3).
77 SALDO-USUARIO-ENT PIC S9(9).
77 SALDO-USUARIO-DEC PIC 9(2).
77 CENT-SALDO-USER PIC S9(11).
77 CENT-IMPOR-USER PIC 9(9).
77 CENT-ACUMULADOR PIC 9(11).
77 CON PIC X(35) VALUE "Ingreso".
77 PRESSED-KEY PIC 9(4).
LINKAGE SECTION.
77 TNUM PIC 9(16).
SCREEN SECTION.
01 BLANK-SCREEN.
05 FILLER LINE 1 BLANK SCREEN BACKGROUND-COLOR BLACK.
* 01 ENTRADA-USUARIO.
* 05 FILLER BLANK ZERO AUTO UNDERLINE
* LINE 13 COL 41 PIC 9(7) USING EURENT-USUARIO.
* 05 FILLER BLANK ZERO UNDERLINE
* LINE 13 COL 49 PIC 9(2) USING EURDEC-USUARIO.
01 ENTRADA-USUARIO.
05 FILLER UNDERLINE
LINE 14 COL 41 PIC 9(3) USING EUR10.
05 FILLER UNDERLINE
LINE 15 COL 41 PIC 9(3) USING EUR20.
05 FILLER UNDERLINE
LINE 16 COL 41 PIC 9(3) USING EUR50.
01 SALDO-DISPLAY.
05 FILLER SIGN IS LEADING SEPARATE
LINE 10 COL 33 PIC -9(7) FROM SALDO-USUARIO-ENT.
05 FILLER LINE 10 COL 41 VALUE ".".
05 FILLER LINE 10 COL 42 PIC 99 FROM SALDO-USUARIO-DEC.
05 FILLER LINE 10 COL 45 VALUE "EUR".
01 SALDO-DISPLAY-FINAL.
05 FILLER SIGN IS LEADING SEPARATE
LINE 11 COL 44 PIC -9(7) FROM SALDO-USUARIO-ENT.
05 FILLER LINE 11 COL 52 VALUE ".".
05 FILLER LINE 11 COL 53 PIC 99 FROM SALDO-USUARIO-DEC.
05 FILLER LINE 11 COL 56 VALUE "EUR".
PROCEDURE DIVISION USING TNUM.
IMPRIMIR-CABECERA.
SET ENVIRONMENT 'COB_SCREEN_EXCEPTIONS' TO 'Y'.
DISPLAY BLANK-SCREEN.
DISPLAY "Cajero Automatico UnizarBank" LINE 2 COL 26
WITH FOREGROUND-COLOR IS BLUE
WITH BACKGROUND-COLOR IS WHITE.
MOVE FUNCTION CURRENT-DATE TO CAMPOS-FECHA.
DISPLAY DIA LINE 4 COL 32.
DISPLAY "-" LINE 4 COL 34.
DISPLAY MES LINE 4 COL 35.
DISPLAY "-" LINE 4 COL 37.
DISPLAY ANO LINE 4 COL 38.
DISPLAY HORAS LINE 4 COL 44.
DISPLAY ":" LINE 4 COL 46.
DISPLAY MINUTOS LINE 4 COL 47.
CONSULTA-ULTIMO-MOVIMIENTO SECTION.
INITIALIZE CENT-ACUMULADOR.
OPEN I-O F-MOVIMIENTOS.
IF FSM <> 00
GO TO PSYS-ERR.
MOVE 0 TO LAST-MOV-NUM.
LEER-ULTIMO-MOV-READ.
READ F-MOVIMIENTOS NEXT RECORD AT END GO TO LAST-MOV-FOUND.
IF MOV-NUM > LAST-MOV-NUM
MOVE MOV-NUM TO LAST-MOV-NUM.
GO TO LEER-ULTIMO-MOV-READ.
LAST-MOV-FOUND.
CLOSE F-MOVIMIENTOS.
CONSULTA-SALDO-USUARIO SECTION.
OPEN INPUT F-MOVIMIENTOS.
IF FSM <> 00
GO TO PSYS-ERR.
MOVE 0 TO LAST-USER-MOV-NUM.
MOVE 0 TO MOV-NUM.
LECTURA-MOV-USER.
READ F-MOVIMIENTOS NEXT RECORD
AT END GO LAST-USER-MOV-FOUND.
IF MOV-TARJETA = TNUM
IF LAST-USER-MOV-NUM < MOV-NUM
MOVE MOV-NUM TO LAST-USER-MOV-NUM.
GO LECTURA-MOV-USER.
LAST-USER-MOV-FOUND.
CLOSE F-MOVIMIENTOS.
IF LAST-USER-MOV-NUM = 0 THEN
MOVE 0 TO SALDO-USUARIO-ENT
MOVE 0 TO SALDO-USUARIO-DEC
MOVE 0 TO CENT-SALDO-USER
GO TO PANTALLA-INGRESO
END-IF.
MOVE LAST-USER-MOV-NUM TO MOV-NUM.
OPEN INPUT F-MOVIMIENTOS.
IF FSM <> 00
GO TO PSYS-ERR.
READ F-MOVIMIENTOS INVALID KEY GO TO PSYS-ERR.
MOVE MOV-SALDOPOS-ENT TO SALDO-USUARIO-ENT.
MOVE MOV-SALDOPOS-DEC TO SALDO-USUARIO-DEC.
COMPUTE CENT-SALDO-USER = (SALDO-USUARIO-ENT * 100)
+ SALDO-USUARIO-DEC.
CLOSE F-MOVIMIENTOS.
PANTALLA-INGRESO SECTION.
INITIALIZE EUR10.
INITIALIZE EUR20.
INITIALIZE EUR50.
DISPLAY "Ingresar efectivo" LINE 8 COL 30.
DISPLAY "Saldo Actual: " LINE 10 COL 19.
DISPLAY SALDO-DISPLAY.
DISPLAY "Por favor,introduzca billetes" LINE 11 COL 19.
* DISPLAY "Cantidad introducida: " LINE 13 COL 19.
Display "Billetes de 10 euros: " LINE 14 COL 19.
DISPLAY "Billetes de 20 euros: " LINE 15 COL 19.
DISPLAY "Billetes de 50 euros: " LINE 16 COL 19.
DISPLAY "Enter - Aceptar" LINE 24 COL 1.
DISPLAY "ESC - Cancelar" LINE 24 COL 66.
CONF2.
ACCEPT ENTRADA-USUARIO ON EXCEPTION
IF ESC-PRESSED THEN
EXIT PROGRAM
ELSE
GO TO CONF2
END-IF.
COMPUTE EURENT-USUARIO = (EUR50 * 50)
+(EUR20 * 20)
+(EUR10 * 10).
COMPUTE CENT-IMPOR-USER = (EURENT-USUARIO * 100).
ADD CENT-IMPOR-USER TO CENT-ACUMULADOR.
* COMPUTE CENT-IMPOR-USER = (EURENT-USUARIO * 100)
* + EURDEC-USUARIO.
* ADD CENT-IMPOR-USER TO CENT-ACUMULADOR.
INSERTAR-MOVIMIENTO SECTION.
OPEN I-O F-MOVIMIENTOS.
IF FSM <> 00
GO TO PSYS-ERR.
ADD CENT-IMPOR-USER TO CENT-SALDO-USER
ON SIZE ERROR GO TO PSYS-ERR.
COMPUTE SALDO-USUARIO-ENT = (CENT-SALDO-USER / 100).
MOVE FUNCTION MOD(CENT-SALDO-USER, 100)
TO SALDO-USUARIO-DEC.
ESCRITURA.
ADD 1 TO LAST-MOV-NUM.
MOVE LAST-MOV-NUM TO MOV-NUM.
MOVE TNUM TO MOV-TARJETA.
MOVE ANO TO MOV-ANO.
MOVE MES TO MOV-MES.
MOVE DIA TO MOV-DIA.
MOVE HORAS TO MOV-HOR.
MOVE MINUTOS TO MOV-MIN.
MOVE SEGUNDOS TO MOV-SEG.
MOVE EURENT-USUARIO TO MOV-IMPORTE-ENT.
MOVE EURDEC-USUARIO TO MOV-IMPORTE-DEC.
MOVE CON TO MOV-CONCEPTO.
MOVE SALDO-USUARIO-ENT TO MOV-SALDOPOS-ENT.
MOVE SALDO-USUARIO-DEC TO MOV-SALDOPOS-DEC.
WRITE MOVIMIENTO-REG INVALID KEY GO TO PSYS-ERR.
CLOSE F-MOVIMIENTOS.
* GO TO PANTALLA-INGRESO.
PANT SECTION.
COMPUTE EURENT-USUARIO = (CENT-ACUMULADOR / 100).
MOVE FUNCTION MOD(CENT-ACUMULADOR, 100)
TO EURDEC-USUARIO.
PERFORM IMPRIMIR-CABECERA THRU IMPRIMIR-CABECERA.
DISPLAY "Ingresar efectivo" LINE 8 COL 30.
DISPLAY "Se han recibido correctamente:" LINE 10 COL 19.
DISPLAY EURENT-USUARIO LINE 10 COL 50.
DISPLAY EURDEC-USUARIO LINE 10 COL 58.
DISPLAY "." LINE 10 COL 57.
DISPLAY "EUR" LINE 10 COL 61.
DISPLAY "El saldo resultante es de:" LINE 11 COL 19.
DISPLAY SALDO-DISPLAY-FINAL.
DISPLAY "Enter - Aceptar" LINE 24 COL 33.
GO TO EXIT-ENTER.
PSYS-ERR.
CLOSE F-MOVIMIENTOS.
PERFORM IMPRIMIR-CABECERA THRU IMPRIMIR-CABECERA.
DISPLAY "Ha ocurrido un error interno" LINE 9 COL 25
WITH FOREGROUND-COLOR IS WHITE
BACKGROUND-COLOR IS RED.
DISPLAY "Vuelva mas tarde" LINE 11 COL 32
WITH FOREGROUND-COLOR IS WHITE
BACKGROUND-COLOR IS RED.
DISPLAY "Enter - Aceptar" LINE 24 COL 33.
EXIT-ENTER.
ACCEPT PRESSED-KEY WITH NO ECHO LINE 24 COL 80
IF ENTER-PRESSED
EXIT PROGRAM
ELSE
GO TO EXIT-ENTER.