Page 1 of 1

Executing JCL iterating through all members in a PDS

Posted: Fri Feb 03, 2012 11:29 pm
by Ramy
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!!!

Posted: Sat Feb 04, 2012 1:41 am
by MrSpock
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.

Posted: Sat Feb 04, 2012 12:35 pm
by Anuj Dhawan
You said iteration - did you mean to use "REXX"?

Posted: Sat Feb 04, 2012 1:59 pm
by Ramy
Anything which could be implemented effectively helps. Could you please help me with REXX code for this?

Posted: Sat Feb 04, 2012 2:59 pm
by Ramy
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?

Posted: Sun Feb 05, 2012 12:09 am
by NicC
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.

Posted: Sun Feb 05, 2012 9:12 pm
by kiran.vits
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.

Posted: Tue Feb 07, 2012 10:56 pm
by Ramy
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

Posted: Tue Feb 07, 2012 10:59 pm
by Ramy
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