Create a loop in a JCL
Moderators: Frank Yaeger, DikDude, Moderator Group
-
- Member
- Posts: 4
- Joined: Thu Nov 27, 2008 3:20 pm
Create a loop in a JCL
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.
For example
step010
step020
step030
if step030.rc > 0
then
re-execute step020+step030 until step030.rc = 0
else
step040
endif.
INTRDR in JCL
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.
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.
Natarajan
Chennai
Chennai
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
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".
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".
Regards,
Anuj
Anuj
-
- Member
- Posts: 4
- Joined: Thu Nov 27, 2008 3:20 pm
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!
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
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.
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.
Natarajan
Chennai
Chennai
-
- Member
- Posts: 4
- Joined: Thu Nov 27, 2008 3:20 pm
internal reader INTRDR in JCL
Try this code
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.
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
//***********************************************************
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.
Natarajan
Chennai
Chennai
-
- Member
- Posts: 4
- Joined: Thu Nov 27, 2008 3:20 pm
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?
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?
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
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 ?
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 ?
Last edited by Anuj Dhawan on Sat Nov 29, 2008 3:26 am, edited 2 times in total.
Regards,
Anuj
Anuj
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
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
Natarajan
Chennai
Chennai
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page