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

How to give complex condition in JCL .


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Mon May 02, 2022 11:20 pm
Reply with quote

Hi All,

If anyone can give some hint or suggestion.

My requirement is ..i have a JOB having two step my 1st step of job calls a rexx program(this rexx program calls another job internally) and my 2 step call another rexx program. i have to put condition is such a way when my first step run successfully only then second step should run.

I am stuck how here because my 1st step calls a rexx and then rexx in return submit a internal Job which starts with P and some random no. like P12234.

How i can put condition in my main JCl so that when my first step run successfully and also the internal job which is being called in 1st step thorugh rexx should also run successfully then only my 2nd step in my main jcl should run.

Please help me.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Mon May 02, 2022 11:30 pm
Reply with quote

Look at the SCHEDULE statement in the JCL reference manual - note, JES2 only.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue May 03, 2022 12:17 am
Reply with quote

Digvijay Singh wrote:
How i can put condition in my main JCl so that when my first step run successfully and also the internal job which is being called in 1st step thorugh rexx should also run successfully then only my 2nd step in my main jcl should run.

Your internal job stands in the way because you are using random job names.

PS: I guess, as with your other request, nothing can be changed in the REXX itself.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 12:42 am
Reply with quote

Should have mentioned, SCHEDULE is part of "JES2 Execution Control Statements", see the "MVS JCL Reference" manual for details. Available since zOS 2.2.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2594
Location: Silicon Valley

PostPosted: Tue May 03, 2022 4:22 am
Reply with quote

Your requirement is wrong.

The second step of the first job should be moved to be the second step of the job that is submitted by the first step.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 8:16 am
Reply with quote

Hi , Thanks for response.

I dnt have two job i have only one job and 1 step is calling rexx and that rexx is calling the another random job .

My 2nd step should run only when my 1st step rc=0 and also the internal job which is being submitted in first step should aslo finished with rc=0.

Hope i am clear now.

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

Global Moderator


Joined: 01 Sep 2006
Posts: 2594
Location: Silicon Valley

PostPosted: Tue May 03, 2022 8:21 am
Reply with quote

Quote:
i have only one job

Quote:
Hope i am clear now.


No, you are not clear at all because two jobs are submitted. It does not matter how they are submitted... they are still two jobs and you seem to have control over both of them.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2594
Location: Silicon Valley

PostPosted: Tue May 03, 2022 9:00 am
Reply with quote

1. Can you tell us how the second job is submitted? If you use the SUBMIT command, you should be able to use OUTTRAP to capture the message displayed.

2. Can you tell us how the random number is generated? You should have 'access' to the number from the rexx program.

3. You can use the SDSF Rexx API to determine the status of the second job.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 10:40 am
Reply with quote

Hi Please see below: dynamically my jobname is created

[
Code:
code]

   END                                                               
 ELSE NOP                                                           
 Time = TIME(LONG)    /* Create job name for package execution job */
 PARSE VAR Time . '.' Seed                                           
 Jobname = 'P'||Seed                                                 

and here is the job which is getting submitted from rexx.

Jobline.1  = '//'Jobname' JOB (DCS,058000DCS-058400,2TES-TC3,TESTTEA
Jobline.2  = "//         '"TIRID"',CLASS=A,MSGCLASS=S,REGION=0M,"   
Jobline.3  = '//          MSGLEVEL=(1,0)'                           
Jobline.4  = '//JOBLIB  DD DISP=SHR,DSN=SYS1.ENDEVOR.CSIQAUTU'     
Jobline.5  = '//         DD DISP=SHR,DSN=SYS1.ENDEVOR.CSIQAUTH'     
Jobline.6  = '//         DD DISP=SHR,DSN=SYS1.ENDEVOR.CONLIB'       
Jobline.7  = "// SET TE='"SUBSTR(Testenv,1,1)"'"                   
Jobline.8  = "// SET TS='"SUBSTR(Targetstage,1,1)"'"               
Jobline.9  = "// SET CCID='"ascd"'"                             
Jobline.10 = "// SET TID='"TIRID"'"                                 
Jobline.11 = "// SET PKG='"Package"'"                               
Jobline.12 = "// SET PCD='"ProjCode"'"                             
Jobline.13 = "// SET JN='"Jobname"'"                               
Jobline.14 = "//ENBP1000 EXEC PGM=NDVRC1,PARM='ENBP1000',DYNAMNBR=15
Jobline.15 = '//NDVRLOG  DD DSN=NDVR.PROD.LOG.ESDS,DISP=SHR'       
Jobline.16 = '//C1MSGS1  DD SYSOUT=*'     




And this job is getting submitted through condition 

                                                                         
 IF VErrorflag = 0 & CCIDErrors = 0 & Inspectrc <= 8 THEN               
   DO                                                                   
     Jobline.1  = '//'Jobname' JOB (DCS,058000DCS-058400,2TES-TC3,TESTTEA
     Jobline.2  = "//         '"TIRID"',CLASS=A,MSGCLASS=S,REGION=0M,"

Jobline.3 = '// MSGLEVEL=(1,0)' [/code]
F2=Split F3=Exit F4=Expand F5=Rfind F6=Rchange
F8=Down F9=Swap F10=Left F11=Right F12=Cancel
Code:
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 1:32 pm
Reply with quote

You can monitor a job using the REXX/SDSF API.
So something like this:
Step 1 generates and submits the 2nd job, then goes into a loop monitoring the progress of the submitted job. When the job has finished then the rc is kept. RC for step 1 is then set based on the rc from job2.
Note that you really should have a wait between the job status checks in the loop.
Use something like this to get the job status:
Code:
zz=isfcalls('ON')                           
isfprefix=userid()   /* <- jobname/prefix */
Address  SDSF "ISFEXEC  ST (delayed)"       
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 2:34 pm
Reply with quote

Thanks for your response.

My job is not available in spool it is being directed to Savers.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 3:13 pm
Reply with quote

You are not makng this easy.
Could you leave the job in spool and only reroute it to a SAVERS class when you have checked it's state?
Otherwise I can only suggest that you rethink the entire process.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 3:27 pm
Reply with quote

I have no other way.

is it possible to set the return code of calling step on the basis of return code of internal job which is getting submitted through rexx..?
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 3:42 pm
Reply with quote

Only if you monitor the submitted job somehow....
Or, can you make the submitted job write a status to a dataset, so that you can monitor the dataset?
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 3:47 pm
Reply with quote

add 3 steps to the submitted job:
at top - (re)create dataset with content 'INIT'.
after, with condcode check:
if cc=0 then write 'OK' to dataset.
if cc<>0 then write 'FAIL' to dataset.

A thought, SAVERS, I believe, have a REXX interface, use that to check status?
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 4:02 pm
Reply with quote

I am sorry if i didnt get this right.

what i am thinking ..

1> 1st step submitted and internal rexx submitted the job ..can we direct this job RC to a data set and if that data set has RC = 00 we can use sort and all to fetch the rc and basis on which we can run 2nd step.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 4:29 pm
Reply with quote

yes, you can add a step to the submitted job to pull the rc from a previous step, and save that info to a dataset. Use the REXX/SDSF API. However do you really need the actual rc, or is zero/notzero sufficient? If so, use the setup I outlined earlier.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 4:41 pm
Reply with quote

when you are saying the submitted job it means interanl job right which is getting submitted from rexx?


add 3 steps to the submitted job:
at top - (re)create dataset with content 'INIT'.
after, with condcode check:
if cc=0 then write 'OK' to dataset.
if cc<>0 then write 'FAIL' to dataset.

yes i am only bother about zero or non zero as of now.
could you give piece of code of the above solution am bad at JCL and new here like what i will check in my 2nd step conditon i am not sure ...?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Tue May 03, 2022 5:03 pm
Reply with quote

First of all you need to understand that any JCL job cannot be called neither from REXX, nor from any other place. All JCL jobs can be only submitted; and after that the job is running independently from its submitter. It may require non-trivial tricks to "check the return code" produced by a step of an independently running job.

In case I knew what your actual intentions are, I would re-design your schema of execution from scratch. Simple things must be done using simple methods.

So far it looks like the flight for Boston to New York with transfer on the Moon. It is possible, but makes no sense.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1315
Location: Vilnius, Lithuania

PostPosted: Tue May 03, 2022 5:19 pm
Reply with quote

You're trying to do what a scheduler does. This is not allowed on this forum!

What would happen if the "random" job never starts?

This thread needs to be locked!
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 148
Location: India

PostPosted: Tue May 03, 2022 6:09 pm
Reply with quote

answer to last two post..

1st> I may be wrong but i am sure we can submit a skelton having batch job through rexx.

2> Sometime you automate the things the requirement could be strange but nothing more you can do about it, we have to find out approach and try your best you can achieve that.

1> My question was very simple i want to capture the rc of internal job and basis on that i will be running my second step.

and i guess we can achive this but being new in the rexx bit of struggle for me.

Thanks for your point of views.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Tue May 03, 2022 6:29 pm
Reply with quote

Digvijay Singh wrote:

1st> I may be wrong but i am sure we can submit a skelton having batch job through rexx.

Once again: you can SUBMIT a JCL produced from a skeleton, but under no circumstances you can CALL a JCL, from anywhere.
My point is: you are not able to understand the principal difference between CALLING, and SUBMITTING.
(And also: the difference between JCL customization from a skeleton as text data, and submitting the same text as JCL code)

Digvijay Singh wrote:

1> My question was very simple i want to capture the rc of internal job and basis on that i will be running my second step.

Your question seems to be simple, but the answer is too complex unless you understand the possibilities to communicate between parallel processes.

Main point: why not to add the whole "second job" as some // IF-ELSE portion of the first job, to be either executed, or bypassed depending on the RC produced by your specific job step? What is the need to split the whole process into two independent JCLs, while they are not really independent???

Digvijay Singh wrote:

and i guess we can achive this but being new in the rexx bit of struggle for me.

It has nothing to do with REXX, or any other language. You need to understand the available options that can be used in MVS to control several INDEPENDENT processes running IN PARALLEL.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Tue May 03, 2022 6:53 pm
Reply with quote

Ok, here is some JCL:
Code:
//S0      EXEC PGM=IEBGENER                 
//SYSPRINT DD SYSOUT=*                       
//SYSIN    DD DUMMY                         
//SYSUT2   DD DISP=SHR,DSN=statds           
//SYSUT1   DD *                             
INIT                                         
//*                                         
//ENBP1000 EXEC PGM=whatever
//*                                         
//        IF ENBP1000.RC = 0 THEN           
//S1      EXEC PGM=IEBGENER                 
//SYSPRINT DD SYSOUT=*                       
//SYSIN    DD DUMMY                         
//SYSUT2   DD DISP=SHR,DSN=statds           
//SYSUT1   DD *                             
OK                                           
//        ELSE                               
//S2      EXEC PGM=IEBGENER                 
//SYSPRINT DD SYSOUT=*                       
//SYSIN    DD DUMMY                         
//SYSUT2   DD DISP=SHR,DSN=statds           
//SYSUT1   DD *                             
FAIL                                         
//        ENDIF                             
//*                                         

But I agree with sergeyken, you really should do your dependent processing in the submitted job.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Tue May 03, 2022 10:12 pm
Reply with quote

It is very difficult to understand something from the tattered cramps of your code.
I try to understand it in my own manner.
Code:

 Time = TIME(LONG)    /* Create job name for package execution job */
 PARSE VAR Time . '.' Seed                                           
 Jobname = 'P'||Seed                                                 

 /* and here is the job which is getting submitted from REXX */

Queue '//'Jobname' JOB (DCS,058000DCS-058400,2TES-TC3,TESTTEA'
Queue "//         '"TIRID"',CLASS=A,MSGCLASS=S,REGION=0M,"   
Queue '//          MSGLEVEL=(1,0)'                           
Queue '//JOBLIB  DD DISP=SHR,DSN=SYS1.ENDEVOR.CSIQAUTU'     
Queue '//         DD DISP=SHR,DSN=SYS1.ENDEVOR.CSIQAUTH'     
Queue '//         DD DISP=SHR,DSN=SYS1.ENDEVOR.CONLIB'       
Queue "// SET TE='"SUBSTR(Testenv,1,1)"'"                   
Queue "// SET TS='"SUBSTR(Targetstage,1,1)"'"               
Queue "// SET CCID='"ascd"'"                             
Queue "// SET TID='"TIRID"'"                                 
Queue "// SET PKG='"Package"'"                               
Queue "// SET PCD='"ProjCode"'"                             
Queue "// SET JN='"Jobname"'"                               
Queue "//ENBP1000 EXEC PGM=NDVRC1,PARM='ENBP1000',DYNAMNBR=15
Queue '//NDVRLOG  DD DSN=NDVR.PROD.LOG.ESDS,DISP=SHR'       
Queue '//C1MSGS1  DD SYSOUT=*'     

/* NO NEED TO SUBMIT THIS FRAGMENT OF THE WHOLE JCL RIGHT HERE!!! */ 
                                                                       
 If VErrorflag = 0 & CCIDErrors = 0 Then Do /* conditionally include Part 2 JCL */                                                                   
     Queue '//* Place here the second part of your job '
     Queue "// IF (ENBP1000.RC <= 8) THEN"
     Queue '//PART2  EXEC PGM=whatever'                                     
     Queue '//. . . all JCL stetements needed for Part 2'                                     
     Queue '//* End of Part 2 conditionally included,
     Queue '//* and conditionally executed as a part of the single JCL'   
     Queue '// ENDIF'   
 End   

/* Now write the whole JCL from program stack into a dataset */
"EXECIO * DISKW OUTJCL (FINIS"

/* here you can submit your single JCL in the same manner you did it before */
                             


From your very long explanation it is still unclear: what are those secret conditions, and where do they come from?
Code:
VErrorflag = 0 & CCIDErrors = 0


P.S.
Now there is no trace of previously used skeletons, and FTS calls?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2594
Location: Silicon Valley

PostPosted: Tue May 03, 2022 11:19 pm
Reply with quote

Quote:
What is the need to split the whole process into two independent JCLs, while they are not really independent???


I think that Digvijay still does not understand that the two jobs run asynchronously. It is undesirable for one job to wait for the other job to execute (it could run much later in the day, or as Prino pointed out: it might not ever run).

I repeat my suggestion:
The second step of the first job should be moved to be the second step of the job that is submitted by the first step.
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 -> CLIST & REXX Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Add condition to a FINDREP SORT card DFSORT/ICETOOL 4
No new posts Concatenate 2 input datasets and give... JCL & VSAM 2
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts Save SYSLOG in a MASS complex All Other Mainframe Topics 3
Search our Forums:

Back to Top