Page 1 of 2

Submit job through rexx based on last RC of JCL step

PostPosted: Wed Apr 24, 2013 11:53 pm
by abhirocksf5
Submit job through rexx based on last RC of JCL last step
Hi, I have written some piece of code and trying to submit that JCL multiple times through rexx. I have trapped the RC of each step of JCL somehow,but not able to use that RC in my rexx program. I can see the RC of each step in spool under SYSTPRT.
Can any one please help me out of these.
see the code below.

MAIN PROGRAM

/*Rexx program to ALLOCATE dataset*/
SAY" PROGRAM TO ALLOCATE DATASET AND INCREMENT VERSION"
INPUT1 ='G0100V00'
B = suBSTR(INPUT1,3,3)
SAY'SUBSTR' = B ---------------->100
DO 3 --------------------------------> JOB will run 3 times based on the condition of RC check below
QUEUE"//TCOM099A JOB (189),'ABHI',MSGCLASS = J,MSGLEVEL(1,1),
QUEUE"// PRTY=15,NOTIFY=TCOM099"
QUEUE"//STEP1 EXEC PGM = IEFBR14"
QUEUE"//DD1 DD DSN ="TCOM099.TEST.INPUT1",DISP=(NEW,CATLG,DELETE),"
QUEUE"// SPACE=(TRK,(5,10),RLSE),"
QUEUE"// DCB=(LRECL=80,BLKSIZE=800,RECFM=FB)"
QUEUE"/* */"
QUEUE"//LASTSTEP EXEC PGM=IRXJCL,PARM='STEPRC'" ----------> REXX MEMBER
QUEUE"//SYSEXEC DD DISP=SHR,DSN=TCOM099.REXX.PGMS"-----> REXX LIBRARY
QUEUE"//SYSTSPRT DD SYSOUT=*
QUEUE"//SYSTSIN DD DUMMY"
QUEUE"//"
QUEUE"$$"
"SUBMIT * END($$)"
/*********************************/
/*HERE I NEED THE JCL RETURN CODE*/
/*********************************/
IF RCSTEP = 0 THEN NOP ------- Since RCSTEP is not assigned with any value so by default RCSTEP =' ' and exiting from loop
ELSE LEAVE
END
A = B+1 ------------------------> 101
INPUT1 = G0||A||V00
SAY'NEW INPUT IS' INPUT1 ----------> G0101V00
END
EXIT

REXX program to capture Return code
/* REXX STEPRC */
/* GET THE STEP NAME AND RETURN CODE */
NUMERIC DIGITS(32) /* ENSURE MAX PRECISION */
TCB=STORAGE(D2X(540),4) /* PSATOLD IN PSA */
JSCB =STORAGE(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */
JCT = STORAGE(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */
THIS_STEP_NO = X2D(C2X(STORAGE(D2X(C2D(JSCB)+228),1)))
/* THIS STEP NO. */
FSCT = STORAGE(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */
/* IS FIRST SCT */
TEMP_SCT = FSCT
DO I = 1 TO (THIS_STEP_NO - 1)
STEP = STORAGE(D2X(C2D(TEMP_SCT)+68),8)
RCSTEP = X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+24),2)))
/* SCTSEXEC IN SCT */
BYPASS = STORAGE(D2X(C2D(TEMP_SCT)+188),1)
IF X2D(C2X(BYPASS)) = 80 THEN /* CHECK IF STEP WAS NOT EXECUTED */
DO
RCSTEP = 'FLUSHED '
END
SAY 'STEP ==>' STEP ' RC ==>' RCSTEP
TEMP_SCT = STORAGE(D2X(C2D(TEMP_SCT)+36),3)
END
EXIT

Can any one please let me know how to use RC trapped here to my MAIN program.

Thank you !!!

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 12:09 am
by MrSpock
Sure.

Use that code "STEPRC" in the last step of your job. It will retrieve the job and step details from the control blocks of that job. Write the results to a dataset.

Then, modify your first REXX exec to look for that dataset. Once the job has finished and that dataset is cataloged, you can open it, read the contents, and take whatever actions you wish to as a result.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 12:15 am
by abhirocksf5
ThankS MrSpock!!
WIthout writing to dataset , can't I directly use the RCSTEP value in my MAIN program??

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 12:30 am
by enrico-sorichetti
*********************************/
/*HERE I NEED THE JCL RETURN CODE*/
/*********************************/


unfortunately not always You can have what You want.
the submitted job runs asynchronously from the submitter
and there will be no communication between the two...

what You are trying to do is to write a RYO scheduling system
and You will get little sympathy and very little help in doing it

there is no reason to keep a job hanging around waiting for somebody to finish

the only way to implement such poor requirement is to do everything
in the same job

or better wrap the <real step> inside a rexx wrapper

but You might be better off by telling the initial requirement instead of
asking how to implement a poor solution for whatever the requirement could be

and anyway the a iefbr14 step will always end with a 0 return code

but if You need to allocate the next three generations why not simply use

//DD1 DD DISP=(NEW,...),DSN=GDGBASE(+1),
//...

//DD2 DD DISP=(NEW,...),DSN=GDGBASE(+2),
//...

//DD3 DD DISP=(NEW,...),DSN=GDGBASE(+3),
//...

much simpler, no need to bother the return codes.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 12:49 am
by abhirocksf5
Thanks for your advise enrico-sorichetti!!
The above program is just a sample snippet of code to understand the requirement.
The actual program for which I am looking for help has many steps including IDCAMS ,IKJEFT01 and SORT steps.
I know its a poor design ,submitting job through REXX holds resources for long time,but then also I want to impliment this since i am using this in development region.

So please share your logic (if any) rather than considering efficiency and poor design.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 1:41 am
by Pedro
submitting job through REXX holds resources for long time


I do not think submitting the job is a problem. But frequently, you see questions in these forums about a rexx programwaiting for the job to end. It is the waiting that is the problem.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 1:42 am
by dick scherrer
Hello and welcome to the forum,

What is to happen when this is promoted to Production? A well-managed system would not allow what you propose to be used . . .

It Would be done using the scheduling system.

Is there some reason you cannot or will not run this in one long "string"? It could be run inline or each process could submit the next on successful completion.

We do not at all encourage home-grown scheduling as many of us have seen entire systems "hurt" by people attempting to do this. Also, almost every mainframe now has one scheculing package or another.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 5:05 am
by steve-myers
The BIG problem with your Rexx gyrations is IBM can, and does, alter the contents of the SWA that your Rexx code is using. What do you do then?

What is wrong with something like this -

//ASTEP EXEC PGM=xxx
... DD statements for the STEP ...
//OK EXEC PGM=IEBGENER,COND=(0,NE,ASTEP)
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD -- Data set containing JOB to run when the RC in ASTEP is 0 --
//SYSUT2 DD SYSOUT=(A,INTRDR)
//SYSIN DD DUMMY

This technique, perhaps with a different SYSUT2 DD statement in the IEBGENER step, would work almost as long as there was a HASP or JES2 system available.

As others have pointed out, you do not want to create a RYO ("Roll Your Own") production job scheduling system. Essentially all production sites are using some sort of ISP developed system that has been available almost as long as my sample JCL. Your site is paying the ISP big bucks to maintain and support the system. USE IT.

I spent several unhappy years maintaining a RYO combination security / tape management system. There were a number of good ideas in this system, but there were a lot of bad ideas, too.
  • Data set security was loosely based on the original RACF idea of what are now called discrete profiles, which ultimately failed.
  • Data set security prevented the used of indexed VTOCs, SMS data set management, and the use of DFSMS/HSM type systems. PDSE was not available while I worked on the system, but it would have precluded PDSE, too. I always thought I could support indexed VTOC, but I never got the chance to work on it. An HSM type system would be RYO.
  • There was nothing like OPERATIONS in the security system.
  • The tape management component did not support multiple systems sharing the tape management catalog.
  • Passwords in the security system were a joke.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 6:14 pm
by abhirocksf5
What is to happen when this is promoted to Production?


Thanks Mr dick scherrer !!!!
I have told already that I am not going to use this in production. The tool for which I am writing code is just for internel purpose. Also there are not many jobs,a few jobs only I wanaa submit. We have schedular available but I dont want to use for this. I am not going to use this tool for more than a month,since i need this at my work , thats why trying to code it out.

On my first post , I have given the sample program snippet. It is almost done . I have trapped the step RC in spool from Control blocks with the help of STORAGE() ,only thing required is to recieve the RC step value in MAIN program.

Is there any way to get the RC value directly to MAIN program without writing to dataset and read that file again.

Re: Submit job through rexx based on last RC of JCL step

PostPosted: Thu Apr 25, 2013 7:33 pm
by dick scherrer
Hello,

Yes, you mentioned it was not for prodeuction, but i wish i had $ for every process i've seen that was for "only a short term use" and somehow has been running for years . . .

Also there are not many jobs,a few jobs only I wanaa submit. We have schedular available but I dont want to use for this.
What a developer "wants" is neither a technical nor business justification. Especially when there are alternatives available. There is no issue with submitting the jobs, only the way you are trying to do this having your code holding resources unnecessarily.

Is there any way to get the RC value directly to MAIN program without writing to dataset and read that file again.
Obtain it and place it in a variable?