Create a loop in a JCL

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
Bart De Weirdt
Member
Posts: 4
Joined: Thu Nov 27, 2008 3:20 pm

Create a loop in a JCL

Post by Bart De Weirdt » Thu Nov 27, 2008 3:23 pm

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.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

INTRDR in JCL

Post by Natarajan » Thu Nov 27, 2008 3:35 pm

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.
Natarajan
Chennai

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Nov 27, 2008 3:45 pm

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".
Regards,
Anuj

Bart De Weirdt
Member
Posts: 4
Joined: Thu Nov 27, 2008 3:20 pm

Post by Bart De Weirdt » Thu Nov 27, 2008 3:58 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!

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

internal reader INTRDR in JCL

Post by Natarajan » Thu Nov 27, 2008 4:10 pm

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.
Natarajan
Chennai

Bart De Weirdt
Member
Posts: 4
Joined: Thu Nov 27, 2008 3:20 pm

Post by Bart De Weirdt » Thu Nov 27, 2008 4:59 pm

thx natarajan

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

Bart

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

internal reader INTRDR in JCL

Post by Natarajan » Thu Nov 27, 2008 6:11 pm

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.
Natarajan
Chennai

Bart De Weirdt
Member
Posts: 4
Joined: Thu Nov 27, 2008 3:20 pm

Post by Bart De Weirdt » Fri Nov 28, 2008 3:51 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?

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Nov 28, 2008 8:57 pm

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 ?
Last edited by Anuj Dhawan on Sat Nov 29, 2008 3:26 am, edited 2 times in total.
Regards,
Anuj

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Fri Nov 28, 2008 9:34 pm

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
Natarajan
Chennai

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 11:06 pm

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others