Page 1 of 1

JCL which starts other JCL

PostPosted: Mon Oct 11, 2021 7:57 pm
by makdiver
Hi,
I have a dataset with several JCL-Member. All theses member can run - but how can I write a JCL, that will start one member after the other out of this dataset ?

Thanks for tips

Michael

Re: JCL which starts other JCL

PostPosted: Mon Oct 11, 2021 9:12 pm
by sergeyken
Different options are available. The most simple one:

1) keep all required jobs one-after-one (or copy them to) a single dataset, or a single member of JCL library
2) assign exactly the same jobname to all included jobs
3) submit the whole JCL stream from this member/DSN, using a single SUBMIT command
4) same-named jobs will be initiated one by one, in the order they had been read by SUBMIT command

This is a very simple solution for this simple task, as it is described.

Re: JCL which starts other JCL

PostPosted: Mon Oct 11, 2021 11:56 pm
by Robert Sample
4) same-named jobs will be initiated one by one, in the order they had been read by SUBMIT command
This isn't how JES2 works. From the manual:
All jobs are queued by job class, priority, and the order in which they finished conversion. This is the queue from which JES2 managed initiators select jobs for execution. See JES2 control of batch job initiation for more details.
If the different jobs with the same name have different job classes, or have different numbers of statements, or have different priorities, then the sequence in which the jobs are executed may vary radically from the sequence the jobs were submitted in.

Re: JCL which starts other JCL

PostPosted: Tue Oct 12, 2021 1:10 am
by willy jensen
Take a look a JES2 scheduling services. If you can modify the jobs to use that, then you can use a simple IEBGENER to read in all the jobs and have them execute as you intend.
Otherwise you can't do it with JCL alone. If you have a WAIT program then you can submit each member by a separate IEBGENER step with a wait between, but still no guarantee.

Re: JCL which starts other JCL

PostPosted: Tue Oct 12, 2021 1:51 am
by sergeyken
Robert Sample wrote:
4) same-named jobs will be initiated one by one, in the order they had been read by SUBMIT command
This isn't how JES2 works. From the manual:
All jobs are queued by job class, priority, and the order in which they finished conversion. This is the queue from which JES2 managed initiators select jobs for execution. See JES2 control of batch job initiation for more details.
If the different jobs with the same name have different job classes, or have different numbers of statements, or have different priorities, then the sequence in which the jobs are executed may vary radically from the sequence the jobs were submitted in.

Of course, the jobs need to have the same CLASS= parameter, etc.
I expected this is obvious, and no need to clarify those details.

Re: JCL which starts other JCL

PostPosted: Tue Oct 12, 2021 2:02 pm
by willy jensen
Strictly speaking, you cannot submit anything with JCL, but you can use JCL to run a program which can.
This will read in (submit) members from a PDS, but the order of execution may not be in that sequence, as previously discussed. It uses the standard utility IEBGENER, but other are available.

//S EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT1 DD DISP=SHR,DSN=your.pds(member1)
// DD DISP=SHR,DSN=your.pds(member2)
and so on and so forth till..
// DD DISP=SHR,DSN=your.pds(membern)
//SYSUT2 DD SYSOUT=(A,INTRDR)

Of course if you want or need something to dynamically build the list of members then you need a program, REXX springs to mind.