-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.sqlrpgle
382 lines (313 loc) · 9.26 KB
/
example.sqlrpgle
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
**free
//===================================================================================
// GENERALITES PROGRAMME
//-----------------------------------------------------------------------------------
// ENTETE PROGRAMME
// ----------------
//
// Nom du programme : MOUTXHTPRO
// Date de création : 06/04/2020
// Titre programme : Moulinette de MAJ ADH1PACPF
//
// Programmeur : YRA
// N° demande : JIRA OAV-1467 Patch OAV C2020-12 - ADH1PACPF :
// Anomalie lors de modifications des paliers
// ----------------------------------------------------------------------------------
// RESUME PROGRAMME
// ----------------
// Moulinettes de MAJ des montants taxe et hors taxe et profil sur les
// paliers de cotisation
//
// Périmètre: tous les paliers où pacmht est à null
//
// ----------------------------------------------------------------------------------
// HISTORIQUE DES MODIFICATIONS
// ----------------------------
//
//
//-----------------------------------------------------------------------------------
//===================================================================================
// SOURCE - PROGRAMME
//-----------------------------------------------------------------------------------
//
// *********************************
// * DECLARATIONS *
// *********************************
//
//==================== DECLARATION DES FORMATS ====================================
ctl-opt dftactgrp(*no) actgrp(*caller) bnddir('OUTILS':'ADHESION');
// Définition des DS
//-------------------
/copy h1frptechs/qcopsrc,s_errords
/copy h1frptechs/qcopsrc,s_jobEnvDs
/copy h1wwadhess/qcopsrc,gettauxds
// Déclaration des constantes
//---------------------------
dcl-c c_adhesion const(4);
dcl-c c_outils const(99);
// Définition des variables
//-------------------------
dcl-s wIdPret packed(11:0);
dcl-s wpacpac packed(11:0);
dcl-s wdateeffetpalier date;
dcl-s wgarantie packed(5:0);
dcl-s wmontantpalier packed(11:2);
dcl-s wmontanttaxe packed(11:2);
dcl-s wmontantht packed(11:2);
dcl-s wpackro packed(11:0);
dcl-s wCompagnie packed(3:0);
dcl-s wtauxTva packed(5:3);
dcl-s wcodePays packed(5:0);
dcl-s wprtdrt date;
dcl-s wdate8 packed(8:0);
dcl-s wMajOK int(10);
dcl-s wNbTraite int(10);
dcl-s wcurscod like(sqlcode);
//Indicateurs d'erreurs
dcl-s errInit ind;
dcl-s errTrtPaliers ind;
dcl-s errRechercheInfosPrets ind;
dcl-s errRechercheTauxTaxe ind;
dcl-s errUpdatePalier ind;
dcl-s werr ind;
dcl-s rc int(10);
dcl-ds TauxTaxeDS likeds(gettauxtaxeds_t);
dcl-ds w_jobSetIdDs likeds(m_jobSetIdDS_t);
// //
dcl-pi *n;
end-pi;
// Déclaration des curseurs
//--------------------------
//Lecture du fichier des paliers
exec sql
declare LecturePaliers cursor for
select pacmpa, pacggi, pacdep, pacpac, packro
from adh1pacpf
where pacmht is null
order by pacggi, pacdep;
//=================== TRAITEMENT PRINCIPAL ===============================
//------------------------------------------------------------------------
monitor;
exsr trt_init;
if not errInit;
exsr trt_paliers;
if errTrtPaliers;
werr = *on;
endif;
else;
werr = *on;
endif;
on-error *all;
m_error('000215'
:*omit
:'Erreur inattendue dans le traitement la mise à jour palier'
:'*Other'
:'INFO'
:'99');
endmon;
exsr trt_finpgm;
//===================== SOUS-PROGRAMMES ===============================
//----------------------------------------------------------------------
// Initialisation environnement
//-----------------------------
begSr trt_init;
rc = 0;
werr = *off;
errInit = *off;
clear w_jobSetidDs;
w_jobSetidDs.idDomaine = c_adhesion;
w_jobSetidDs.idApplication = c_outils;
rc = m_jobSetId(w_jobSetidDs);
m_Errrct(m_errrctDs);
if rc <> 0;
errInit = *on;
m_error ('000245'
:*omit
:'Erreur initialisation environnement '
:'*Other'
:'INFO '
:%char(rc));
else;
m_error ('000252'
:*omit
:'DEBUT: Traitement mise à jour ADH1PACPF '
:'*Other'
:'INFO '
:'00');
endif;
endsr;
// Traitement des paliers pour un prêt
//-----------------------------------------------------
begSr trt_paliers;
errTrtPaliers = *off;
clear wMajOK;
clear wNbTraite;
clear wdate8;
clear wmontantpalier;
clear wgarantie;
clear wdateeffetpalier;
clear wpacpac;
clear wpackro;
//Ouverture du curseur
exec sql open LecturePaliers;
wcurscod = sqlcode;
if wcurscod = 0;
exec sql fetch LecturePaliers
into :wmontantpalier, :wgarantie,
:wdateeffetpalier, :wpacpac, :wpackro;
wcurscod = sqlcode;
dow wcurscod = 0;
wNbTraite = wNbTraite + 1;
exsr rechercheInfosPrets;
if not errRechercheInfosPrets;
exsr rechercheTauxTaxe;
if not errRechercheTauxTaxe;
exsr updatePalier;
if not errUpdatePalier;
wMajOK = wMajOK + 1;
else;
errTrtPaliers = *on;
endif;
else;
errTrtPaliers = *on;
endif;
else;
errTrtPaliers = *on;
endif;
exec sql fetch LecturePaliers
into :wmontantpalier, :wgarantie,
:wdateeffetpalier, :wpacpac, :wpackro;
wcurscod = sqlcode;
if wcurscod = 100;
leave;
endif;
enddo;
if wcurscod <> 100;
errTrtPaliers = *on;
m_error('000379'
:*omit
:'errreur à la sortie du curseur LecturePaliers '
:'*SQL'
:'INFO'
:%char(sqlcode));
endif;
exec sql close LecturePaliers;
else;//erreur lors de l'ouverture du curseur
errTrtPaliers = *on;
m_error('000391'
:*omit
:'Une erreur s''est produite lors de '
+'l''ouverture du curseur LecturePaliers'
:'*SQL'
:'INFO'
:%char(sqlcode));
endif;
endsr;
// Recherche infos Prets
//----------------------
begsr rechercheInfosPrets;
errRechercheInfosPrets = *off;
clear wCompagnie;
clear wcodePays;
clear wprtdrt;
exec sql
select prtcie, bqeptx, prtdrt
into :wCompagnie, :wcodePays, :wprtdrt
from p1abqepf inner join t4pprtpf on prtban = bqeban
where prtkro = :wpackro;
if sqlcode <> 0;
errRechercheInfosPrets = *on;
m_error('000419'
:*omit
:'errreur recherche infos prêt, '
+%char(wpackro)
:'*SQL'
:'INFO'
:%char(sqlcode));
endif;
endsr;
// Recherche taux taxe par garantie
//---------------------------------
begsr rechercheTauxTaxe;
errRechercheTauxTaxe = *off;
clear TauxTaxeDS;
clear rc;
clear wTauxTva;
clear wmontantht;
clear wmontanttaxe;
wdate8 = %dec(wprtdrt);
TauxTaxeDS.Pays = wcodePays;
TauxTaxeDS.Cie = wCompagnie;
TauxTaxeDS.Garantie = wgarantie;
TauxTaxeDS.DateCalcul = wdate8;
//Récupération du taux de taxe
rc = m_getTauxTaxe(TauxTaxeDS);
if rc = 0;
wTauxTva = TauxTaxeDS.TauxTaxe;
wTauxTva = (wTauxTva / 100) + 1;
wmontantHT = %dech(wmontantPalier/wTauxTva:11:2);
wmontantTaxe = wmontantPalier - wmontantHT ;
else;
errRechercheTauxTaxe = *on;
m_error('000458'
:*omit
:'errreur recherche taux de taxe pour le prêt, '
+%char(wpackro)
:'*Other'
:'INFO'
:%char(rc));
endif;
endsr;
// Traitement mise à jour palier
//------------------------------
begsr updatePalier;
errUpdatePalier = *off;
exec sql
update adh1pacpf
set pacmht = :wmontantHT,
pacmtx = :wmontantTaxe,
pacpro = 'A0OAV'
where f_idpret = :wPackro
and pacpac = :wpacpac;
if sqlcode <> 0;
errUpdatePalier = *on;
m_error('000484'
:*omit
:'Erreur mise à jour palier pour le '
+'prêt '+ %char(wPackro)
:'*Sql'
:'INFO'
:%char(sqlcode));
else;
m_error('000492'
:*omit
:'Mise à jour palier OK pour le '
+'prêt '+ %char(wPackro)
:'*Sql'
:'INFO'
:%char(sqlcode));
endif;
endsr;
// Traitement fin programme
//-------------------------
begSr trt_finpgm;
if not werr;
m_error ('000507'
:*omit
:'FIN: Traitement mise à jour ADH1PACPF '
+%char(wNbTraite) + ' prêts traités'
:'*Other'
:'INFO '
:'00');
else;
m_error ('000515'
:*omit
:'FIN: Traitement mise à jour ADH1PACPF avec des erreurs '
+%char(wMajOK) + '/' + %char(wNbTraite)
+' prêts traités'
:'*Other'
:'INFO '
:'01');
endif;
*inLr = *on;
endsr;