-
Notifications
You must be signed in to change notification settings - Fork 0
/
db2-tp35.cbl
250 lines (194 loc) · 18.1 KB
/
db2-tp35.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
IDENTIFICATION DIVISION.
PROGRAM-ID PGMDB215.
**********************************************************
* *
* TRABAJO PRACTICO 35 *
* CHECK-POINT 31 BATCH ACTUALIZADOR *
* 9-11-2022 *
* *
**********************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CLIENTE ASSIGN DDCLIEN
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS KEY-CLI
FILE STATUS IS FS-CLI.
DATA DIVISION.
FILE SECTION.
FD CLIENTE.
01 REG-CLIENTE.
03 KEY-CLI PIC X(17).
03 FILLER PIC X(227).
**************************************
WORKING-STORAGE SECTION.
**************************************
77 FS-CLI PIC XX VALUE SPACES.
01 WS-STATUS-FIN PIC X.
88 WS-FIN-LECTURA VALUE 'Y'.
88 WS-NO-FIN-LECTURA VALUE 'N'.
77 WS-SQLCODE PIC +++999 USAGE DISPLAY VALUE ZEROS.
77 WS-PGMRUT PIC X(8) VALUE 'PGMRUT'.
01 WS-FECHA.
03 WS-ANIO PIC 99 VALUE ZEROS.
03 WS-MES PIC 99 VALUE ZEROS.
03 WS-DIA PIC 99 VALUE ZEROS.
01 WS-FECHA-FINAL.
03 WS-SS PIC 99 VALUE ZEROS.
03 WS-AA PIC 99 VALUE ZEROS.
03 FILLER PIC X VALUE '-'.
03 WS-MM PIC 99 VALUE ZEROS.
03 FILLER PIC X VALUE '-'.
03 WS-DD PIC 99 VALUE ZEROS.
COPY TBVCLIEN.
77 WS-TOT-LEI PIC 999 VALUE ZEROS.
77 WS-TOT-INS PIC 999 VALUE ZEROS.
77 WS-TOT-ERR PIC 999 VALUE ZEROS.
77 WS-PRINT PIC ZZ9 VALUE ZEROS.
01 WS-CLI-NOMAPE PIC X(30) VALUE SPACES.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE TB99CLIE
END-EXEC.
LINKAGE SECTION.
01 LK-FECHA.
03 LK-FECHASHORT.
05 LK-SIGLO PIC 99.
05 LK-ANIO PIC 99.
05 LK-MES PIC 99.
05 LK-DIA PIC 99.
03 FILLER PIC X(22).
***************************************************************.
PROCEDURE DIVISION USING LK-FECHA.
**************************************
* *
* CUERPO PRINCIPAL DEL PROGRAMA *
* *
**************************************
MAIN-PROGRAM.
PERFORM 1000-INICIO THRU F-1000-INICIO.
PERFORM 2000-PROCESO THRU F-2000-PROCESO
UNTIL WS-FIN-LECTURA.
PERFORM 9999-FINAL THRU F-9999-FINAL.
F-MAIN-PROGRAM. GOBACK.
**************************************
* *
* CUERPO INICIO APERTURA ARCHIVOS *
* *
**************************************
1000-INICIO.
SET WS-NO-FIN-LECTURA TO TRUE.
ACCEPT WS-FECHA FROM DATE
INITIALIZE LK-FECHA
MOVE 20 TO LK-SIGLO
MOVE WS-ANIO TO LK-ANIO
SUBTRACT 1 FROM WS-MES
MOVE WS-MES TO LK-MES
CALL WS-PGMRUT USING LK-FECHA
IF RETURN-CODE EQUAL 05
SET WS-FIN-LECTURA TO TRUE
DISPLAY 'ERROR RUTINA FECHA: 05'
ELSE
MOVE LK-SIGLO TO WS-SS
MOVE LK-ANIO TO WS-AA
MOVE LK-MES TO WS-MM
MOVE LK-DIA TO WS-DD
END-IF.
OPEN INPUT CLIENTE.
IF FS-CLI IS NOT EQUAL '00'
DISPLAY '* ERROR EN OPEN CLIENTE = ' FS-CLI
MOVE 9999 TO RETURN-CODE
SET WS-FIN-LECTURA TO TRUE
END-IF.
PERFORM 3000-LEER-CLIENTE THRU 3000-F-LEER-CLIENTE.
F-1000-INICIO. EXIT.
**************************************
2000-PROCESO.
MOVE WK-CLI-TIPO-DOCUMENTO TO DB-CL-TIPDOC
MOVE WK-CLI-NRO-DOCUMENTO TO DB-CL-NRODOC
MOVE WK-CLI-NRO-CLIENTE TO DB-CL-NROCLI
MOVE WS-FECHA-FINAL TO DB-CL-FECNAC
MOVE WK-CLI-SEXO TO DB-CL-SEXO
EXEC SQL
INSERT INTO ITPLZRY.TB99CLIE
(TIPDOC,
NRODOC,
NROCLI,
NOMAPE,
FECNAC,
SEXO)
VALUES (:DB-CL-TIPDOC,
:DB-CL-NRODOC,
:DB-CL-NROCLI,
:WS-CLI-NOMAPE,
:DB-CL-FECNAC,
:DB-CL-SEXO)
END-EXEC.
EVALUATE SQLCODE
WHEN +0
ADD 1 TO WS-TOT-INS
WHEN +100
SET WS-FIN-LECTURA TO TRUE
WHEN -803
ADD 1 TO WS-TOT-ERR
DISPLAY 'CLIENTE DUPLICADO'
WK-CLI-TIPO-DOCUMENTO ' ' WK-CLI-NRO-DOCUMENTO
WHEN OTHER
ADD 1 TO WS-TOT-ERR
MOVE SQLCODE TO WS-SQLCODE
DISPLAY 'ERROR ACCESO TABLA: ' WS-SQLCODE
MOVE 9999 TO RETURN-CODE
SET WS-FIN-LECTURA TO TRUE
END-EVALUATE.
PERFORM 3000-LEER-CLIENTE THRU 3000-F-LEER-CLIENTE.
F-2000-PROCESO. EXIT.
**************************************
* LECTURA CLIENTES *
**************************************
3000-LEER-CLIENTE.
MOVE SPACES TO WK-TBCLIE
MOVE SPACES TO WS-CLI-NOMAPE
READ CLIENTE INTO WK-TBCLIE
EVALUATE FS-CLI
WHEN '00'
ADD 1 TO WS-TOT-LEI
STRING WK-CLI-NOMBRE-CLIENTE DELIMITED BY ' '
' ' DELIMITED BY SIZE
WK-CLI-APELLIDO-CLIENTE DELIMITED BY ' '
INTO WS-CLI-NOMAPE
END-STRING
WHEN '10'
SET WS-FIN-LECTURA TO TRUE
WHEN OTHER
DISPLAY '* ERROR EN LECTURA CLIENTE = ' FS-CLI
SET WS-FIN-LECTURA TO TRUE
END-EVALUATE.
3000-F-LEER-CLIENTE. EXIT.
**************************************
* *
* CUERPO FINAL CIERRE DE FILES *
* *
**************************************
9999-FINAL.
MOVE WS-TOT-LEI TO WS-PRINT
DISPLAY 'TOTAL NOVEDADES LEIDAS = ' WS-PRINT
MOVE WS-TOT-INS TO WS-PRINT
DISPLAY 'TOTAL NOVEDADES INSERTADAS = ' WS-PRINT
MOVE WS-TOT-ERR TO WS-PRINT
DISPLAY 'TOTAL NOVEDADES ERRONEAS = ' WS-PRINT
CLOSE CLIENTE
IF FS-CLI IS NOT EQUAL '00'
DISPLAY '* ERROR EN CLOSE CLIENTE = '
FS-CLI
MOVE 9999 TO RETURN-CODE
SET WS-FIN-LECTURA TO TRUE
END-IF.
* EXEC SQL
* ROLLBACK
* END-EXEC.
F-9999-FINAL.
EXIT.
*