IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

JCL submitting JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Thu Jul 09, 2020 3:14 pm
Reply with quote

I have a specific requirement to submit JCL within a Job, using the internal reader. So, Job X invokes Job Y.

This can be done easily using IEBGENER. But what I need to do is hold the submitting job (X) until the called job (Y) has finished.

The proper solution is to use a job scheduler like OPC. However, for various reasons, I need to use an alternative approach for the time being.

My solution was:

Job X :
Step1 : submit job Y
Step2 : wait 10 seconds, to give time for Y to enqueue file resource
Step3 : take MOD lock on that file resource


Step3 has the effect of holding Job X until Job Y finishes and releases file resource.

Worked perfectly under Z/OS 2.2.
Fails under Z/OS 2.3 for reason/s unknown.

So ... can someone provide possible explanation .. OR provide a more elegant solution.

as I said, at this stage using OPC or Control-M is not possible.
Job Y runs under different LPAR to Job X.

Any help appreciated
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jul 09, 2020 6:32 pm
Reply with quote

split job X in two parts ...
last step of X part ONE submits Y
last step of Y submits X part TWO

remember
the topic belongs to the category of 'topics not eligible for discussion'
at the section ... write Your own scheduler

and as such should be locked
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1245
Location: Bamberg, Germany

PostPosted: Thu Jul 09, 2020 6:51 pm
Reply with quote

Consider using JOBGROUP (available since z/OS 2.2) to build your own scheduling logic w/ z/OS and JES2 means.
Back to top
View user's profile Send private message
WilliamDownie

New User


Joined: 01 Jul 2020
Posts: 21
Location: UK

PostPosted: Sun Jul 26, 2020 5:23 pm
Reply with quote

Could you give job x and job y the same job name ? Job y can then not start until job x has completed.

You say that "Job Y runs under different LPAR to Job X.", so I don't know if my suggestion will work for you.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Sun Jul 26, 2020 6:11 pm
Reply with quote

Code:
//JOBX     JOB ...
//A       EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSUT1   DD  -- Data set containing JOBY --
//SYSUT2   DD  SYSOUT=(A,INTRDR)
//SYSIN    DD  DUMMY
  ....
//LAST    EXEC PGM=IEFBR14
//LOCKDS   DD  DISP=OLD,VOL=REF=SYS1.SVCLIB,
//             DSN=a-data-set-name


//JOBY     JOB ...
  ....
//LOCK     EXEC PGM=IEFBR14
//LOCKDS   DD  DISP=OLD,VOL=REF=SYS1.SVCLIB,
//             DSN=a-data-set-name
The data set in the LOCKDS DD statement does not have to actually exist; the VOL=REF parameter just ensures there is a volume to allocate.

I did this solution something like 25 years ago. It worked like a charm. Obviously it will work on one system. For two systems, both systems must share data set ENQs. If they are not doing this, it will not work, which is probably why it did not work in the z/OS 2.2 and z/OS 2.3 environment.

z/OS gets the data set resources for all data sets specified in the JCL in a job before the first step executes, and releases data sets when the last step in the job that specifies the data set completes. The weakness in this solution is JOBY will appear to be running until JOBX actually completes.

The one job name Mr. Downie proposed will work with one system, but not multiple systems.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sun Jul 26, 2020 6:21 pm
Reply with quote

Hope you are doing this in test only environment, are you ?
How many times are you planning to have this loop on ? What’s the break for the loop ?

If it’s test and you know it takes say 1 min then why not just wait such time and resubmit instead of coding any fancy ?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1245
Location: Bamberg, Germany

PostPosted: Sun Jul 26, 2020 9:58 pm
Reply with quote

Sample with JOBGROUP (JES2 z/OS 2.2+):
Code:
//SCHEDULE EXEC PGM=IEBGENER                     
//SYSPRINT DD SYSOUT=*                           
//SYSUT1   DD DATA,DLM=##                         
//MYGROUP  JOBGROUP                               
//JOBX     GJOB                                   
//         AFTER NAME=JOBY                       
//JOBY     GJOB                                   
//MYGROUP  ENDGROUP                               
//                                               
//JOBX     JOB ..                                 
//         SCHEDULE JOBGROUP=MYGROUP             
/*JOBPARM S=ANY                                   
//NICEGUY  EXEC PGM=IEFBR14                       
//                                               
//JOBY     JOB ..                                 
//         SCHEDULE JOBGROUP=MYGROUP             
/*JOBPARM S=ANY                                   
//LADY1ST  EXEC PGM=BPXBATCH,PARM='SH sleep 1m'   
//STDOUT   DD PATH='/dev/null'                   
//STDOUT   DD PATH='/dev/null'                   
//STDERR   DD PATH='/dev/null'                   
##                                               
//SYSUT2   DD  SYSOUT=(A,INTRDR)                 
//SYSIN    DD  DUMMY

Seems to work as desired:
Code:
$HASP890 JOB(MYGROUP)                                         
$HASP890 JOB(MYGROUP)   JOB GROUP JOB LIST                     
$HASP890                JOB NAME  JOBID     JOB STAT  COMP STAT
$HASP890                --------  --------  --------  ---------
$HASP890                JOBY      JOB65366  ACTIVE    ACTIVE   
$HASP890                JOBX      JOB65365  PEND DEP  PENDING 

and
Code:
$HASP1300 JOBX registered to job group MYGROUP         
$HASP1300 JOBY registered to job group MYGROUP         
$HASP1301 JOBY in job group MYGROUP queued for execution
$HASP373 JOBY     STARTED - WLM INIT  - SRVCLASS BATCH 
$HASP395 JOBY     ENDED - RC=0000                       
$HASP1301 JOBX in job group MYGROUP queued for execution
$HASP373 JOBX     STARTED - WLM INIT  - SRVCLASS BATCH 
$HASP395 JOBX     ENDED - RC=0000                       
$HASP1304 job group MYGROUP is complete
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts submitting feedback for manuals All Other Mainframe Topics 3
This topic is locked: you cannot edit posts or make replies. ERROR WHILE SUBMITTING LOAD JOB JCL & VSAM 12
No new posts Can SYSIN errors be rectified without... JCL & VSAM 17
No new posts Comparing a PS & PDS, submitting ... JCL & VSAM 21
No new posts specify region while submitting batch... JCL & VSAM 4
Search our Forums:

Back to Top