Author: vinu78
Subject: Reply to: JCL to Set Return code based on DB2 SQL query result
Posted: Tue Mar 14, 2017 6:44 pm (GMT 5.5)
Hi All,
I did something like this.
Wrote 3 steps
- Step1 will make use of IKJEFT01 with DNSTIAUL program and execute SELECT query and get the rows in a dataset
- Step2 uses IDCAMS utility and set Return code based on Record count
If rec count is 2, set RC as 0. Else if rec count is 1, set RC as 8. Or if empty file, set RC as 4.
/*
Execute STEP03 only if RC is < 5
The problem here is that, if file with rec count is 1, that comes from STEP01, then STEP02 will set RC as 8 and for rest of the proc steps after STEP03, I have to deal with MAXCC 8. Is there any way to reset the max return code back to 0, immediately after STEP03.
Thanks
Vinu
Subject: Reply to: JCL to Set Return code based on DB2 SQL query result
Posted: Tue Mar 14, 2017 6:44 pm (GMT 5.5)
Hi All,
I did something like this.
Wrote 3 steps
- Step1 will make use of IKJEFT01 with DNSTIAUL program and execute SELECT query and get the rows in a dataset
- Step2 uses IDCAMS utility and set Return code based on Record count
If rec count is 2, set RC as 0. Else if rec count is 1, set RC as 8. Or if empty file, set RC as 4.
Code: |
//STEP02 EXEC PGM=IDCAMS //DD1 DD DSN=TEST.ABC.FILE,DISP=SHR //SYSIN DD * PRINT INFILE(DD1) COUNT(2) IF LASTCC GT 0 - THEN DO PRINT INFILE(DD1) COUNT(1) IF LASTCC EQ 0 THEN DO - SET LASTCC = 8 END ELSE - SET LASTCC = 4 END |
/*
Execute STEP03 only if RC is < 5
The problem here is that, if file with rec count is 1, that comes from STEP01, then STEP02 will set RC as 8 and for rest of the proc steps after STEP03, I have to deal with MAXCC 8. Is there any way to reset the max return code back to 0, immediately after STEP03.
Thanks
Vinu