Page 1 of 1

Create a loop in a JCL

Posted: Thu Nov 27, 2008 3:23 pm
by Bart De Weirdt
Is it possible to loop a certain amount of steps in a JCL?

For example

step010
step020
step030
if step030.rc > 0
then
re-execute step020+step030 until step030.rc = 0
else
step040
endif.

INTRDR in JCL

Posted: Thu Nov 27, 2008 3:35 pm
by Natarajan
Bart,

I didnot heard about looping in JCL.
You may need to use JCL INTRDR for this purpose. This will submit another job, or the same job again.

Posted: Thu Nov 27, 2008 3:45 pm
by Anuj Dhawan
Hello Bart De Weirdt and welcome to the Forums,

You need to re-think how to implement your requirement (the requirement is not to loop in some step - that is your attempt to meet the requirement). If you post the actual requirement, someone may have a suggestion.

I suspect that you want to loop until some condition is met. This could be hours or worse case - never.

If several people implemented their process doing as you want to do, the mainframe would come to a complete halt because all of the initiators/partitions were "looping".

Posted: Thu Nov 27, 2008 3:58 pm
by Bart De Weirdt
some details ....

step010
executes a program that extracts parts from a database

step020
calculates in batch the sales prices for all those parts on current date

step030
compares the sales prices with the purchase prices and updates them
it also produces an outputfile (O1) with parts that have different prices in the future

As long as O1 isn't empty, step020 and step030 should be re-executed!

I'm trying to put this logic in the JCL, because the impact is too big if I change the Cobol programs!

internal reader INTRDR in JCL

Posted: Thu Nov 27, 2008 4:10 pm
by Natarajan
after step030 include following.
1. include a step to find whether O1 is empty or not.
2. use IF condition after that.
execute INTRDR step to submit this same JCL again dynamically, if O1 is not empty.


If you have any questions on below... let me know.. i will help you.
1. How to find whether file contains the data or not.
2. submit the same job using INTRDR dynamically.

Posted: Thu Nov 27, 2008 4:59 pm
by Bart De Weirdt
thx natarajan

checking if the file is empty is no problem, but I've never used the INTRDR ... some help is welcome!

Bart

internal reader INTRDR in JCL

Posted: Thu Nov 27, 2008 6:11 pm
by Natarajan
Try this code

Code: Select all

//********************************************************************** 
//**************THIS IS A ROUTINE WHICH CALLS ANOTHER JCL ***            
//********************************************************************** 
//* STEP02 : RE-SUBMIT THE JCL //*************************************** 
//STEP02  EXEC PGM=IEBGENER                                              
//SYSTSPRT  DD SYSOUT=*                                                  
//SYSPRINT  DD SYSOUT=*                                                  
//SYSUT1   DD DSN=DXX.XXXX.XXXX.JCLLIB(AUTO),DISP=SHR              
//SYSUT2   DD SYSOUT=(A,INTRDR)                                          
//SYSIN      DD DUMMY                                                    
//***********************************************************     
DXX.XXXX.XXXX.JCLLIB(AUTO) is the JCL location to be submitted.
This can be other JCL or the Same JCL.

Caution : Make sure this loop should be ended. otherwise, this job may go into infinate loop. Since you are going to have IF condition, i assume at some point of time, file is empty and the loop will end there.

Posted: Fri Nov 28, 2008 3:51 pm
by Bart De Weirdt
Natarajan,

It works perfectly, but I have one last question.

In the program that produces file O1, I set the returncode to 04.
After the execution of the program I test the returncode

if returncode = 04
then
re-execute job (using intrdr)
else
continue with last steps
end-if

but somehow the system takes over and doesn't get to the if-statement!!!

-JOBNAME STEPNAME PROCSTEP RC EXCP CPU SRB CLOCK
-HAPBWP8A HMPPRP8A STEP030 00 334 .00 .00 .01
-HAPBWP8A HMPPRP8A STEP040 04 271 .00 .00 .00
IEF451I HAPBWP8A STEP040 HMPPRP8A - ENDED BY CC 0004 - TIME=1
-HAPBWP8A ENDED. NAME- TOTAL CPU TIME=
-NOT_EXECUTED_STEP_TABLE BEGIN
-JOBNAME STEPNAME PROCSTEP STEPNO
-HAPBWP8A HMPPRP8A STEP02 3
-HAPBWP8A HMPPRP8A STEP050 4
-HAPBWP8A HMPPRP8A STEP060 5
-HAPBWP8A HMPPRP8A STEP998 6

any idea how I could bypass this?

Posted: Fri Nov 28, 2008 8:57 pm
by Anuj Dhawan
Hi Brat,

Please post the JCL used & on what condition do you set the RC=4 in the program, I'd guess - when the file is empty ?

Posted: Fri Nov 28, 2008 9:34 pm
by Natarajan
Hi Brat,

As Anuj suggested, if you post your JCL, we dont required to spend much time
to help you.

Any how, let me guess, what you coded.

You might have used wrong syntax of IF RC, Please refer below tutorial for this.
http://www.geocities.com/srcsinc/drona/ ... ter10.html

Topic deleted by Admin

Posted: Mon Feb 01, 2016 11:06 pm
by academyindia4
<< Content deleted By Admin >>