Return to the Systems Tips
Ending selective sessions in batch
Hi! We had a super guy here that wrote 2 CL programs and an RPG program for us to do exactly what you are saying. At night, at a certain time, we kick off this CL. The CL will write to a file every active job within the QINTER subsystem. The file contains the job attributes Then, an RPG program will read the file and, based on user critereia, will end the job unless the user is one that is designated not to end. The RPG program uses a CL to end the jobs that are active. Here is the CL code for the first program:
0001.00 PGM 0002.00 DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10) 0003.00 DCL VAR(&USER) TYPE(*CHAR) LEN(10) 0004.00 DCL VAR(&JOBNUMBER) TYPE(*CHAR) LEN(6) 0005.00 WRKSBSJOB SBS(QINTER) USER(*ALL) 0006.00 RTVJOBA JOB(&JOBNAME) USER(&USER) NBR(&JOBNUMBER) 0007.00 CPYSPLF FILE(QPDSPSBJ) TOFILE(QGPL/QINTERJOBS) + 0008.00 JOB(&JOBNUMBER/&USER/&JOBNAME) SPLNBR(*LAST) 0009.00 CALL PGM(QGPL/ENDJOBS) 0010.00 DLTSPLF FILE(QPDSPSBJ) JOB(&JOBNUMBER/&USER/&JOBNAME) 0011.00 ENDPGM Here is the RPG source: 0001.00 FQinterjobsIF F 256 Disk 0002.00 * 0003.00 IQinterjobsNS 01 0004.00 I 4 13 Job 0005.00 I 17 26 User 0006.00 I 30 35 Number 0007.00 I 39 43 Type 0008.00 I 49 54 Status 0009.00 I 68 73 Function 0010.00 * 0011.00 C Read Qinterjobs 0012.00 C DoW Not %EOF 0013.00 C If (User <> 'AnyUser ' And 0014.00 C User <> 'SomeUser ' And 0033.00 C Status = 'ACTIVE' And 0034.00 C Type = 'INTER' 0035.00 C Call 'EJQINTER02' 0036.00 C Parm Job 0037.00 C Parm User 0038.00 C Parm Number 0039.00 C EndIf 0040.00 C Read Qinterjobs 0041.00 C EndDo 0042.00 C Eval *InLR = *On Here is the CL source for the program to end the selected jobs: 0001.00 PGM PARM(&JOB &USER &NUMBER) 0002.00 DCL VAR(&JOB) TYPE(*CHAR) LEN(10) 0003.00 DCL VAR(&USER) TYPE(*CHAR) LEN(10) 0004.00 DCL VAR(&NUMBER) TYPE(*CHAR) LEN(6) 0005.00 MONMSG CPF0001 0006.00 ENDJOB JOB(&NUMBER/&USER/&JOB) OPTION(*IMMED) + 0007.00 ADLINTJOBS(*ALL) 0008.00 ENDPGMI hope this helps you!
Kevin Jennings
[report a broken link by clicking here]