Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Problem related Looping in JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
GauravKudesiya
Warnings : 1

New User


Joined: 11 Oct 2008
Posts: 74
Location: Chicago, IL

PostPosted: Wed Sep 16, 2009 4:00 am    Post subject: Problem related Looping in JCL
Reply with quote

Hello All,
I am facing a problem in looping in JCL.
I am using Proc.
Looping is like below:

MainJCL ----> Proc 1

Proc1---(Ends with some cond)---> Proc2(When Proc 2 ends)-----> Proc1

Proc2 ----(Ends with some cond)---> Proc2

But i am getting :
PROC PROCESSING STOPPED BECAUSE OF A RECURSIVE EXECUTION
'PROC2'.
PROC PROCESSING STOPPED BECAUSE OF A RECURSIVE EXECUTION
'PROC1'.


Is there any other other method to loop a proc untill the condition is matched...

The recursion is more that 15 times....
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Wed Sep 16, 2009 7:36 am    Post subject: Reply to: Problem related Looping in JCL
Reply with quote

Huh? icon_confused.gif

I'm not sure exactly what you're doing, but proc's can only be nested so deep:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B670/5.3?SHELF=EZ2ZO10J&DT=20070427231644
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Sep 16, 2009 8:46 am    Post subject:
Reply with quote

1. JCL cannot be looped -- it executes from first line to last line.
2. Although I don't see anything in the manual, I don't believe you can use procedures recursively in JCL. There's nothing to support the recursion in the JCL, and that could be considered a form of looping (already known to not work).
3. Nested procedures are very clearly limited to 15 deep in the manual. If you need more than that, you will have to find another way.
4. Batch jobs that do conditional processing can be very tricky to get right, and from the fuzziness of your post (incorrect terminology, incorrect concepts, just to name two), I doubt you are going to be able to accomplish what you want with what you are doing.

So why don't you clear all preconceived notions about how to do what you are attempting, tell us exactly what you want to do (without mentioning anything about method) and see what gets suggested.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Sep 16, 2009 11:01 am    Post subject:
Reply with quote

Hi,

How does your process know when to quit?
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Sep 16, 2009 11:05 am    Post subject:
Reply with quote

And when you get these messages:
Code:
PROC PROCESSING STOPPED BECAUSE OF A RECURSIVE EXECUTION
'PROC2'.
PROC PROCESSING STOPPED BECAUSE OF A RECURSIVE EXECUTION
'PROC1'
are not they associated with some "message ID" -- they don't seem to be some standard messages icon_confused.gif. Are they output from some JCL checker or something else?

And as others have said, JCL cannot be looped, it's just another incorrect concept among many.
Back to top
View user's profile Send private message
GauravKudesiya
Warnings : 1

New User


Joined: 11 Oct 2008
Posts: 74
Location: Chicago, IL

PostPosted: Wed Sep 16, 2009 5:26 pm    Post subject:
Reply with quote

Hello,

In the PROC1, i am processing a sequencial file FILE1(Containing about 400 Records.)

For every record of FILE1, a file is generated as FILE2(Contains dynamic no of records).

In PROC2, I have process FILE2, it has some cobol pgms and some jcl steps,and it is not possible to cover it in a single cobol pgm.

When PROC2, ends i have to process Record2 of FILE1(Through Proc1), which again calls PROC2 to process the output FILE2(corrs to record2 of File1).

Is there any other option left for looping... as the recursion is limited to 15.

@ANUJ: Those error msgs are from JCL Check.

Thanks.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Sep 16, 2009 5:45 pm    Post subject:
Reply with quote

Your options are:

1. Set up your JCL to run 400 times (once for each record in FILE 1).
2. Do a process redesign that looks at what needs to be done, how it needs to be done, and gets rid of the supposed need to loop in JCL.

You need to be aware that once a job is submitted, it goes through the converter / interpreter of JES. At that point, nothing your executing programs can do can impact the job that is running -- NOTHING! You cannot perform actions at run time that will affect your executing JCL -- it has been fixed in stone at that point. You could redesign the process so a separate job is submitted for each record in FILE 1 but you cannot do anything in the current job to change steps that haven't executed yet.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Sep 18, 2009 12:27 pm    Post subject:
Reply with quote

Quote:
Is there any other option left for looping... as the recursion is limited to 15.
No one has said this. They talked about "nested PROCs" and nested procedures are limited to 15 deep as far as manual goes. If you need more than that, you will have to find another way, as Robert has said.

It seems there can be alternate solutions to your problem, if you start over and describe the problem instead of telling what you've done to achieve that. And that, ofsourse, is not working as you say that in very ab initio.
Back to top
View user's profile Send private message
GauravKudesiya
Warnings : 1

New User


Joined: 11 Oct 2008
Posts: 74
Location: Chicago, IL

PostPosted: Fri Sep 18, 2009 5:34 pm    Post subject: Hello...
Reply with quote

Hello all...
I am done with looping with JCL...
Instead of using PROC, i am using JCL itself....
and while calling the proc ... i am submitting the another JCL by Internal Reader.....
Submitting JCL2 from JCL1 and JCL1 from JCL2 until my condition is matched..

Thanks for all your Concerns...
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 18, 2009 9:28 pm    Post subject:
Reply with quote

Hello,

Quote:
i am submitting the another JCL by Internal Reader.....
Submitting JCL2 from JCL1 and JCL1 from JCL2 until my condition is matched..
Hopefully, there is some mechanism to terminate after some number of interations - i.e. what if the condition is never matched. . .?
Back to top
View user's profile Send private message
GauravKudesiya
Warnings : 1

New User


Joined: 11 Oct 2008
Posts: 74
Location: Chicago, IL

PostPosted: Fri Sep 18, 2009 9:43 pm    Post subject:
Reply with quote

Hello,
Let me explain the whole Senario.

JCL1
Code:
//Step1 PGM=COB1(Takes input from FILE1,1st Record,Set RC=16 at EOF)
//IF STEP1.RC LT 16 (Breaks When EOF1)
//STEP2 PGM=PGM=ISRSUPC (Creats some WKFILE)
//STEP3 PGM=COB2 (REFORMATS WKFILE to FILE2)
//STEP4 (Submit JCL2)
//ENDIF


JCL2
Code:
//STEP6 PGM=COB3(takes input from FILE2,Creat file3,SET RC=16 AT EOF)
//IF STEP6.RC LT 16
//STEP7 PGM=ACFBATCH
//STEP8 PGM=COB4(Adds record to file3)
//STEP9 PGM=ACFBATCH(Fed FILE3)
//STEP10 (SubmitJCL2)  Breaks wneb EOF2
//ENDIF
//STEP5 JCL1(To process 2nd record of file1)


JCL1 always call JCL2 for all Records of FILE1
JCL2 always calls itself for all records of FILE2
JCL2 submit JCL1 when EOF2
Breaks when EOF1


And EOF Cobol is setting a RC to 16, on which IF condition is present to break, and every time 1 record is processd by i time RUN of COBOL.

So it is not possible, that the condition never meet.

Thanks.
Back to top
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Fri Sep 18, 2009 10:30 pm    Post subject:
Reply with quote

Please see below code. STEP1 will be executed 10 times by submitting itself.
Code:

//JOBCARD JOB ...
//STEP1   EXEC PGM=IEFBR14
//*
//STEP2   EXEC PGM=IEBGENER
//SYSUT1    DD *
NEW RECORD
//SYSUT2    DD DSN=&SYSUID..COUNTER,DISP=(MOD,CATLG,DELETE),
//             UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
//SYSPRINT  DD SYSOUT=*
//SYSIN     DD DUMMY
//*
//STEP3   EXEC PGM=ICETOOL
//INFILE    DD DSN=&SYSUID..COUNTER,DISP=SHR
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//TOOLIN    DD *
 COUNT FROM(INFILE) EQUAL(10)
//*
// IF (STEP3.RC=0) THEN
//STEP4   EXEC PGM=IKJEFT01,
//             PARM='SUBMIT ''&SYSUID..JCL(LOOP)'''
//SYSTSPRT  DD SYSOUT=*
//SYSTSIN   DD DUMMY
//*
// ELSE
//STEP5   EXEC PGM=IEFBR14
//DELETE    DD DSN=&SYSUID..COUNTER,DISP=(MOD,DELETE,DELETE),
//             UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
// ENDIF
//
Back to top
View user's profile Send private message
GauravKudesiya
Warnings : 1

New User


Joined: 11 Oct 2008
Posts: 74
Location: Chicago, IL

PostPosted: Fri Sep 18, 2009 10:35 pm    Post subject:
Reply with quote

Hi Dominickim
This case can be considered when we know the number of recurssion.
But what if the recurssion is dynamic..??

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Sep 18, 2009 10:38 pm    Post subject:
Reply with quote

This is not a JCL loop. This is a job running, submitting another job, then ending. The second job submits a third job, then ends, and so forth. Depending upon site standards, such a scheme probably cannot be promoted to production since the scheduler system would have problems.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 18, 2009 11:01 pm    Post subject:
Reply with quote

Hello,

Strongly suggest a re-design be considered. . .

I suspect that the same thing you need to do (which has not been described yet) has been done on hundreds or thousands of applications without requiring this particular flip-flop loop in the jcl. . .

If you describe the business requirement (rather than what is being attempted technically to meet the requirement), someone may have a more useful suggestion.
Back to top
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Fri Sep 18, 2009 11:04 pm    Post subject:
Reply with quote

Hello GauravKudesiya,
You can change the STEP2 and STEP3 in order to generate condition code to stop submitting, sample that I showed you is only using counter. I think there are different ways to make condition code, for example when file is empty, not cataloged, migrated, etc, even you can delete STEP2 and 3 and change the STEP1 to your COBOL program to set the condition code like you did.


Robert Sample,
Thanks for your comments. You are right. I was just trying to show him to find another way to do it.
Back to top
View user's profile Send private message
GauravKudesiya
Warnings : 1

New User


Joined: 11 Oct 2008
Posts: 74
Location: Chicago, IL

PostPosted: Fri Sep 18, 2009 11:18 pm    Post subject:
Reply with quote

I DO AGREE THAT THE DESIGN IS NOT UPTO THE MARK.

Requirment:
Need to build the ACF2 Rules, for 400 IDS on there new UID.
Have to give access on all the Transaction, on which they have.

LIMITATION:
1) We have to take input from FILE, Sequential ONE-BY-ONE as Rules for Trans can not be compile for all IDs together.

2) There will be tons of Trans pre ID, and if will be decompiled in different files,it is not possible to give referance of all files in a cobol, as new rule have to be created by COBOL.

3) Also need to find out the access on those ID by a Utility, so need to come out of COBOL.

4) So its a mix n match of COBOL and JCL, so have to process each INPUT One-by-One and tehn again Process the Trans ONE-By-ONE.

Processin of Tran is also Mix-n-Match of COBOL and JCL.


Hope its put some light on this Design Pattern.
Thanks,
Gaurav
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sun Sep 20, 2009 8:12 pm    Post subject:
Reply with quote

GauravKudesiya wrote:
I DO AGREE THAT THE DESIGN IS NOT UPTO THE MARK.
System is yours, design is yours -- consequences would be yours!

Good Luck...
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Mon Sep 21, 2009 3:06 am    Post subject:
Reply with quote

If I were a system administrator or systems programmer and saw this kind of implementation, lets just say (to be kind), someone would get a stern talking to (as they were led out the door).

You are creating a system with hundreds or thousands of separate jobs where a single small bug can cause the whole mess to be self replicating and out of control, potentially bringing down the entire system. Each job could need its own initiator, and of course, the whole process might take days, weeks or months depending on the availability of initiators. It also breaks the ability to do performance prioritization as a single unit of work (I use the term loosely here), scheduling, system analysis and probably other things.

Use JCL for what it is meant to do - control one process. There is no reason that your main program can not invoke your ACFBATCH, COB4 and ACFBATCH routines as its own subtasks. In my opinion, this whole process should be a single job. You can call programs dynamically from COBOL and do dynamic allocations.

A job is not a subroutine and should not be used as such.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us