Executing JCL iterating through all members in a PDS

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
Ramy
Member
Posts: 5
Joined: Fri Feb 03, 2012 10:54 pm

Executing JCL iterating through all members in a PDS

Post by Ramy » Fri Feb 03, 2012 11:29 pm

Hi There,

I require a favour on the below idea,

Requirement Description:

I would like to run a JCL which runs by iterating through all the members in the PDS given.

For Example:

JCL:

//JOB1 JOB 'IBM',CLASS=A,NOTIFY=&SYSUID
//STEP1 EXEC PGM1
//COBOL.SYSIN DD DISP=SHR,DSN=SAMPLE.PDS(MEM1)
//COBOL.SYSOUT DD DISP=NEW,DSN=SAMPLE.OUTPUT(+1)
......
//SYSPRING DD SYSOUT=*

Here the PDS "SAMPLE.PDS" consists of several other members like MEM2,MEM3,MEM4 etc... I would like to use the same jcl to execute
iterating through all members in the given PDS and resulting output to be stored in the GDG "SAMPLE.OUTPUT(+1)" for each execution.

Could someone help on this please?
Thanks!!!

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Sat Feb 04, 2012 1:41 am

My first thought would be to setup the initial member name in an INCLUDEd library and use SET to make the member name a variable, i.e.

where the library member "MEM" is a SET statement:

// SET MEM='MEM1'

and then is included in the job
//JOB1 JOB 'IBM',CLASS=A,NOTIFY=&SYSUID
// JCLLIB ORDER=... (if necessary)
// INCLUDE MEMBER=MEM
...
//COBOL.SYSIN DD DISP=SHR,DSN=SAMPLE.PDS(&MEM)

and then I'd have a job step write the next member name to use into the library, and then re-submit the job. And so on until all of the members were accounted for.

<update>
Actually, even easier. Just use a JCL Procedure. Call the procedure once for each member needed, passing the member name and relative generation number as symbolic parameters.

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

Post by Anuj Dhawan » Sat Feb 04, 2012 12:35 pm

You said iteration - did you mean to use "REXX"?
Regards,
Anuj

Ramy
Member
Posts: 5
Joined: Fri Feb 03, 2012 10:54 pm

Post by Ramy » Sat Feb 04, 2012 1:59 pm

Anything which could be implemented effectively helps. Could you please help me with REXX code for this?

Ramy
Member
Posts: 5
Joined: Fri Feb 03, 2012 10:54 pm

Post by Ramy » Sat Feb 04, 2012 2:59 pm

MrSpock wrote:My first thought would be to setup the initial member name in an INCLUDEd library and use SET to make the member name a variable, i.e. where the library member "MEM" is a SET statement: // SET MEM='MEM1' and then is included in the job //JOB1 JOB 'IBM',CLASS=A,NOTIFY=&SYSUID // JCLLIB ORDER=... (if necessary) // INCLUDE MEMBER=MEM ... //COBOL.SYSIN DD DISP=SHR,DSN=SAMPLE.PDS(&MEM) and then I'd have a job step write the next member name to use into the library, and then re-submit the job. And so on until all of the members were accounted for. Actually, even easier. Just use a JCL Procedure. Call the procedure once for each member needed, passing the member name and relative generation number as symbolic parameters.
<Reply>

Thanks so much!

I would like to get more insight interms of the actual code to get better understanding. May i request you for the same?

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Sun Feb 05, 2012 12:09 am

JCL is a) site specific for things such as various jobcard parameters and sysout classes to be used and b) dependent on the program being executed and its requirements - datasets, space etc. As a result we cannot really give you assistance beyond saying - look at jobs that work in your installation, know which bits to change for your userid, know what programs you need to run, know which DDnames each program needs and which datasets need to be associated with each DDname. Syntax can be found in the JCL Language Reference manual and the JCL Users Guide.
Regards
Nic

kiran.vits
Member
Posts: 8
Joined: Wed Jan 25, 2012 6:55 pm

Post by kiran.vits » Sun Feb 05, 2012 9:12 pm

Hi Ramy,

can you explain whether your Requirement is to run all the jobs or running based on RC of previous job..

Rexx code can do better for this requirement..

Check for your requiremnet in REXX Section.. If you i not get the answer start a new post in REXX section.
Gaining Knowledge

Ramy
Member
Posts: 5
Joined: Fri Feb 03, 2012 10:54 pm

Post by Ramy » Tue Feb 07, 2012 10:56 pm

NicC wrote:JCL is a) site specific for things such as various jobcard parameters and sysout classes to be used and b) dependent on the program being executed and its requirements - datasets, space etc. As a result we cannot really give you assistance beyond saying - look at jobs that work in your installation, know which bits to change for your userid, know what programs you need to run, know which DDnames each program needs and which datasets need to be associated with each DDname. Syntax can be found in the JCL Language Reference manual and the JCL Users Guide.
<Reply>

Thanks for the suggestions

Ramy
Member
Posts: 5
Joined: Fri Feb 03, 2012 10:54 pm

Post by Ramy » Tue Feb 07, 2012 10:59 pm

kiran.vits wrote:Hi Ramy,

can you explain whether your Requirement is to run all the jobs or running based on RC of previous job..

Rexx code can do better for this requirement..

Check for your requiremnet in REXX Section.. If you i not get the answer start a new post in REXX section.
<Reply>

Hi Nicc,

My requirement is to run all the jobs irrespective of the RC of the previous job. I shall check the same in REXX section.

Thaks for the suggestion

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