-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT_SUBF_SQL.SQLRPGLE
More file actions
executable file
·509 lines (375 loc) · 11 KB
/
T_SUBF_SQL.SQLRPGLE
File metadata and controls
executable file
·509 lines (375 loc) · 11 KB
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
/copy modules/qcopysrc,hspec_h
//*************************************************************************
// Program . . . . . T_SCRN
//
// Created on . . .
// by . . .
//
// Description . . . SQL Subfile Screen Template
//
// To Compile:
// *> CRTSQLRPGI OBJ(&O/&ON) SRCFILE(&L/&F) SRCMBR(&N) -
// *> DBGVIEW(*SOURCE)
// *> DLTSPLF FILE(&N) SPLNBR(*LAST)
//
// CHANGE LOG:
// Date | Name | Description
// -----------------------------------------------------------------------
// | |
// | |
// | |
//*************************************************************************
// Files
F
// Printer/Display Files
FT_DSPF_SFLCF E WORKSTN sfile(SFL01:rrn01)
//*************************************************************************
// Named Constants
D
/copy modules/qcopysrc,status_h
// Named Indicators
D indicatorPtr S * Inz(%Addr(*IN))
D DS Based(IndicatorPtr)
/copy modules/qcopysrc,scrn_h
D continueProcessing...
D S N inz(*on)
D changeMade S N
// SQL Fields
D sqlStatement S 2048A varying
D SqlResult DS qualified
/copy modules/qcopysrc,sql_h
// Subfile Fields
D rrn01 S 4P 0 inz(0)
//*************************************************************************
// Misc Fields
D
//*************************************************************************
// External Program Procedures
// Internal Subprocedures
D Init PR
D Main PR
D SubfileFilled PR N
D ProcessSubfile PR
D Add PR
D Change PR
D Remove PR
D Display PR
D ProcessScreen PR
D action 1A const
D ClearScreen PR
D IsValidData PR N
D MoveToScreen PR
D MoveFromScreen PR
D ResetIndicators...
D PR
D BuildSqlStmt PR
D OpenCursor PR 5A
D FetchNext PR 5A
D CloseCursor PR 5A
// External Subprocedures
///copy modules/qsrvsrc,string_h
//*************************************************************************
// Entry Parms
D T_SUBF PR extpgm('T_SUBF')
D T_SUBF PI
//*************************************************************************
/free
Init();
Main();
*inlr = *on;
/end-free
P*--------------------------------------------------
P* Procedure name: Init
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Init B
D Init PI
/free
exec sql
set option naming = *sys, commit = *none, usrprf = *user,
dynusrprf = *user, datfmt = *iso, closqlcsr = *endmod;
pgm = 'T_SUBF';
changeMade = *on;
return;
/end-free
P Init E
P*--------------------------------------------------
P* Procedure name: Main
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Main B
D Main PI
/free
dow (not F3) and (not F12);
sflDsp = SubfileFilled();
write OVR01;
exfmt CTL01;
ResetIndicators();
// TODO: INSERT CODE HERE
enddo;
return;
/end-free
P Main E
P*--------------------------------------------------
P* Procedure name: SubfileFilled
P* Purpose: Fill the subfile
P* Returns:
P*--------------------------------------------------
P SubfileFilled B
D SubfileFilled PI N
D isFilled S N
/free
isFilled = *on;
if (not changeMade);
hCsrLoc = hCsrRrn;
if (rrn01 > 0);
return *on;
else;
return *off;
endif;
endif;
sflClear = *on;
write CTL01;
sflClear = *off;
rrn01 = 0;
hCsrLoc = 1;
BuildSqlStmt();
if (OpenCursor() = SQL_SUCCESS);
dow (FetchNext() = SQL_SUCCESS) and (rrn01 < 9999);
// TODO: INSERT CODE HERE
rrn01 += 1;
write SFL01;
enddo;
endif;
CloseCursor();
if (rrn01 < 1);
isFilled = *off;
endif;
return isFilled;
/end-free
P SubfileFilled E
P*--------------------------------------------------
P* Procedure name: ProcessSubfile
P* Purpose:
P* Returns:
P*--------------------------------------------------
P ProcessSubfile B
D ProcessSubfile PI
/free
monitor;
readc SFL01;
dow (not %eof());
// TODO: INSERT CODE HERE
sel = ' ';
update SFL01;
readc SFL01;
enddo;
on-error *all;
// add error-handling code if needed
endmon;
return;
/end-free
P ProcessSubfile E
P*--------------------------------------------------
P* Procedure name: Add
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Add B
D Add PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P Add E
P*--------------------------------------------------
P* Procedure name: Change
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Change B
D Change PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P Change E
P*--------------------------------------------------
P* Procedure name: Remove
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Remove B
D Remove PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P Remove E
P*--------------------------------------------------
P* Procedure name: Display
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Display B
D Display PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P Display E
P*--------------------------------------------------
P* Procedure name: ProcessScreen
P* Purpose:
P* Returns:
P*--------------------------------------------------
P ProcessScreen B
D ProcessScreen PI
D action 1A const
/free
// TODO: INSERT CODE HERE
return;
/end-free
P ProcessScreen E
P*--------------------------------------------------
P* Procedure name: ClearScreen
P* Purpose:
P* Returns:
P*--------------------------------------------------
P ClearScreen B
D ClearScreen PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P ClearScreen E
P*--------------------------------------------------
P* Procedure name: IsValidData
P* Purpose: Validate the data on the screen
P* Returns: True or False
P*--------------------------------------------------
P IsValidData B
D IsValidData PI N
D isValid S N
/free
isValid = *on;
// TODO: INSERT CODE HERE
return isValid;
/end-free
P IsValidData E
P*--------------------------------------------------
P* Procedure name: MoveToScreen
P* Purpose:
P* Returns:
P*--------------------------------------------------
P MoveToScreen B
D MoveToScreen PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P MoveToScreen E
P*--------------------------------------------------
P* Procedure name: MoveFromScreen
P* Purpose:
P* Returns:
P*--------------------------------------------------
P MoveFromScreen B
D MoveFromScreen PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P MoveFromScreen E
P*--------------------------------------------------
P* Procedure name: ResetIndicators
P* Purpose:
P* Returns:
P*--------------------------------------------------
P ResetIndicators...
P B
D ResetIndicators...
D PI
/free
// TODO: INSERT CODE HERE
return;
/end-free
P ResetIndicators...
P E
P*--------------------------------------------------
P* Procedure name: BuildSqlStmt
P* Purpose:
P* Returns:
P*--------------------------------------------------
P BuildSqlStmt B
D BuildSqlStmt PI
/free
gSqlStatement = ' ';
return;
/end-free
P BuildSqlStmt E
P*--------------------------------------------------
P* Procedure name: OpenCursor
P* Purpose:
P* Returns:
P*--------------------------------------------------
P OpenCursor B
D OpenCursor PI 5A
/free
exec sql
close c1;
exec sql
prepare sel from :gsqlstatement;
if sqlStt = SQL_SUCCESS;
exec sql
declare c1 cursor for sel;
exec sql
open c1;
endif;
return sqlStt;
/end-free
P OpenCursor E
P*--------------------------------------------------
P* Procedure name: FetchNext
P* Purpose:
P* Returns:
P*--------------------------------------------------
P FetchNext B
D FetchNext PI 5A
/free
exec sql
fetch c1 into :gresultds;
return sqlstt;
/end-free
P FetchNext E
P*--------------------------------------------------
P* Procedure name: CloseCusor
P* Purpose:
P* Returns:
P*--------------------------------------------------
P CloseCursor B
D CloseCursor PI 5A
/free
exec sql
close c1;
return sqlstt;
/end-free
P CloseCursor E
P*--------------------------------------------------
P* Procedure name: Template
P* Purpose:
P* Returns:
P*--------------------------------------------------
P*Template B
D*Template PI
*
*/free
*
*
*
* return;
*
*/end-free
P*Template E