Submit another JCL as a step from main JCL based on RC of the previous step {via Internal Reader} - automation

I have a requirement wherein I have to submit 10 JCL's. Every JCL is coded to give MAXXCC=0 when completed good.
I want to call all the JCL's from a main JCL so that I don't have to submit all the JCL's manually.
If this is not possible through internal reader, please suggest any other workaround.
THIS IS HOW I CODED THEM CURRENTLY:
//*************************************************************
//* STEP 1: Run job 2
//*************************************************************
//*
//STEP02 EXEC PGM=IEBGENER
//SYSUT1 DD DISP=SHR,DSN=HLQ.MYPDS(JCL2)
//SYSUT2 DD SYSOUT=(,INTRDR)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//*
//*************************************************************
//* STEP 3: Run job 3
//*************************************************************
//*
//STEP03 EXEC PGM=IEBGENER,COND=(0,EQ,STEP0)
//SYSUT1 DD DISP=SHR,DSN=HLQ.MYPDS(JCL3)
//SYSUT2 DD SYSOUT=(,INTRDR)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//*

Scheduling System
As other suggested use the scheduling system, I would think all mainframe systems
would have some sort of scheduler. Running Jobs in sequence is there bread and butter
of Scheduling systems.
You do need to learn about scheduling systems and the sooner the better. Ask at work !!!
Other options do exist
JCL Chaining - Each job submit the next job
Basically you can have each job submit the next job
e.g.
Job 1:
// --- Job 1 JCL
//*
// --- JCL to submit Job 2
Job 2:
// --- Job 2 JCL
//*
// --- JCL to submit Job 3
If you use this method I would create a JCL proc (say SUBNEXT)
// --- Job 1 JCL
//*
// EXEC SUBNEXT,NEXT=JOB2
You can use the JCLLIB
statement to use your own PROCLIB (PDS where you store SUBNEXT). To use JCLLIB:
//MYJOB1 JOB ...
//MYLIBS1 JCLLIB ORDER=MY.PROCS.JCL
Jes 3 scheduling
If using Jes-3; There is in-built job control. Only use this
option if you know what you are doing other wise the operation staff will get upset.
Basically make sure you use the flush option

Related

JCL Job for z/OS to execute SRCHFOR or LISTCAT for datasets

I need to create a batch job for searching a data set list; I need to submit the job over FTP.
I am a complete newbie in JCL, so could anyone help me with an example job with SRCHFOR-command?
I need to also create a job for the IDCAMS utility command Listcat
I would be really thankful only for an example job.
Given you indicated you don't know where to start here is a sample job that will run the search in the first step and run IDCAMS to execute a Listcat in the second step.
This link has some useful information on SuperC.
Note: Your jobcard will need to be customized based on your installation's requirements. This job can be submitted via FTP and the subsequent output can be retrieved via FTP as well.
//SRCHCMP JOB (CCCCCCCC),'HOGSTROM',
// MSGLEVEL=(1,1),
// MSGCLASS=O,
// CLASS=A,
// NOTIFY=&SYSUID
//*
//SRCHFOR EXEC PGM=ISRSUPC,PARM=('SRCHCMP,ANYC')
//NEWDD DD DSN=USER1.TEST.CNTL,DISP=SHR
//OUTDD DD SYSOUT=*
//SYSIN DD *
SRCHFOR 'NEWDD'
/*
//*
//IDCAMS EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ENTRY('USER1.TEST.CNTL') ALL
/*
//
Output from the first step will look like this:
ISRSUPC - MVS/PDF FILE/LINE/WORD/BYTE/SFOR COMPARE UTILITY- ISPF
FOR z/OS 2019/02/26 22.45 PAGE 1 LINE-#
SOURCE SECTION SRCH DSN: USER1.TEST.CNTL
SRCHFOR --------- STRING(S) FOUND
-------------------
8 //NEWDD DD DSN=USER1.TEST.CNTL,DISP=SHR
11 SRCHFOR 'NEWDD'
ISRSUPC - MVS/PDF FILE/LINE/WORD/BYTE/SFOR COMPARE UTILITY- ISPF
FOR z/OS 2019/02/26 22.45 PAGE 2
SEARCH-FOR SUMMARY SECTION SRCH DSN: USER1.TEST.CNTL
LINES-FOUND LINES-PROC MEMBERS-W/LNS MEMBERS-WO/LNS COMPARE-COLS
LONGEST-LINE
2 4436 1 41 1:80 80
PROCESS OPTIONS USED: ANYC
THE FOLLOWING PROCESS STATEMENTS (USING COLUMNS 1:72) WERE PROCESSED:
SRCHFOR 'NEWDD'
Output from the IDCAMS Listcat looks like this:
IDCAMS SYSTEM SERVICES TIME: 22:45:34 02/26/19 PAGE 1
LISTCAT ENTRY('USER1.TEST.CNTL') ALL
NONVSAM ------- USER1.TEST.CNTL
IN-CAT --- CATALOG.T70502
HISTORY
DATASET-OWNER-----(NULL) CREATION--------2017.089
RELEASE----------------2 EXPIRATION------0000.000
ACCOUNT-INFO-----------------------------------(NULL)
SMSDATA
STORAGECLASS -----CLASS2 MANAGEMENTCLASS---(NULL)
DATACLASS --------(NULL) LBACKUP ---0000.000.0000
ENCRYPTIONDATA
DATA SET ENCRYPTION-----(NO)
VOLUMES
VOLSER------------T70502 DEVTYPE------X'3010200F' FSEQN------------------0
ASSOCIATIONS--------(NULL)
ATTRIBUTES
IDCAMS SYSTEM SERVICES TIME: 22:45:34 02/26/19 PAGE 2
THE NUMBER OF ENTRIES PROCESSED WAS:
AIX -------------------0
ALIAS -----------------0
CLUSTER ---------------0
DATA ------------------0
GDG -------------------0
INDEX -----------------0
NONVSAM ---------------1
PAGESPACE -------------0
PATH ------------------0
SPACE -----------------0
USERCATALOG -----------0
TAPELIBRARY -----------0
TAPEVOLUME ------------0
TOTAL -----------------1
THE NUMBER OF PROTECTED ENTRIES SUPPRESSED WAS 0
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0
IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0
Here is a reference to the SuperC utility
Another approach, if you are more familiar with the Unix side of the house, would be to consider doing these things via USS or TSO. For USS (Unix System Services), check out my blog:
https://makingdeveloperslivesbetter.wordpress.com/2019/01/06/mvs-utilities-an-almost-real-world-example/
If nothing else, reading the code for the various utilities (they are mostly just shell scripts) will help you map from Unix concepts to z/OS (MVS) concepts.

No output when debugging File Tayloring using ISPFTTRC

I am attempting to debug a small file tailoring job but don't get any output when attempting to use the trace command ISPFTTRC which is described at
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.f54dg00/ispfttrc.htm#ispfttrc
The REXX interprets without warnings.
I have also tried coding the command as
"ISPFTTRC LIST"
but this did not work.
I'd like to:
Get the ISPFTTRC command to return some output since it will be useful for future debugging.
Fix the problem with the job.
Any help would be much appreciated, thanks.
Here is the JCL:
//DOIT EXEC PGM=IKJEFT01,
// PARM='ISPSTART CMD(NDRACMQ)'
//SYSPROC DD DISP=SHR,DSN=&SYSUID..ALL.REXX
//* --- ISPF FILES ---
//ISPSLIB DD DISP=SHR,DSN=&SYSUID..ALL.SKELS
//* --- OUTPUTS ---
//ISPFILE DD DISP=SHR,DSN=&SYSUID..ALL.SKELS(NDSACMO) tailored output
//ISPFTTRC DD DISP=SHR,DSN=&SYSUID..ISPFTTRC debugging output
//* --- MORE ISPF FILES ---
//ISPPROF DD DSN=&&ISPPROF,DISP=(NEW,DELETE,DELETE),
// LRECL=80,RECFM=FB,DSORG=PO,SPACE=(TRK,(2,2,2))
//ISPPLIB DD DISP=SHR,DSN=&SYSUID..ALL.PARMLIB needed? I think not
//ISPTLIB DD DISP=(NEW,DELETE,DELETE),DSN=&&ISPTLIB,
// SPACE=(TRK,(1,1,1)),LIKE=SYS1.SYSTLIB
// DD DISP=SHR,DSN=SYS1.SYSTLIB
//ISPMLIB DD DISP=SHR,DSN=SYS1.SYSMLIB
//* --- OTHER FILES ---
//SYSPRINT DD SYSOUT=*
//ABNLDUMP DD DUMMY
//SYSTSIN DD DUMMY
//SYSTSPRT DD SYSOUT=*
The REXX (simplified):
/* REXX - Bulk ACM queries */
ISPFTTRC LIST
"ISPEXEC FTOPEN"
ele=aaaaa
"ISPEXEC FTINCL NDSACMQ"
ele=bbbbb
"ISPEXEC FTINCL NDSACMQ"
"ISPEXEC FTCLOSE"
exit
The skeleton code from &SYSUID..ALL.SKELS(NDSACMQ):
)CM *-----------------------------------------------------------------*
)CM * Skeleton SCL used to create bulk ACM queries. *
)CM *-----------------------------------------------------------------*
LIST USING COMPONENTS FOR
ELEMENT &ELE ENVIRONMENT *
SYSTEM * SUBSYSTEM *
TYPE * STAGE NUMBER *
OPTIONS
.
Output was going to a dynamically allocated file &SYSUID.**.ISPFT.TRACE.
The way to code the ISPFTTRC command in the REXX was simply "ISPFTTRC" without the quotes, this gives output.
Checking the RC from the command within the REXX was helpful.
I will be able to resolve the problem with the job now that I have trace output.

How can I run my Rexx program as a batch job?

I have a Rexx program that I want to run as a batch job. How can I do this?
This is my program :-
/* Rexx – HELLO – Write Hello World */
Say "hello World"
The program is located as member HELLO in the PDS ME.USER.EXEC.
A valid JOB CARD for my installation is (our environment includes ISPF/PDF as opposed to ROSCOE):-
//MYJOB JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
Note! this has been written as a tutorial
There are a number of ways that you can run the program via batch. I will cover 3 ways all of which are different according to the environment (i.e. what they can utilise.)
Method 1 - Run the program in a Rexx environment.
This entails running the program IRXJCL and passing the name of the program (i.e. the PDS's member name) via the PARM field (you can also pass parameters; accessing them via a PARSE ARG statement).
IRXJCL requires (normally) 3 DDNAMES they are SYSEXEC (The PDS where the program is located), SYSTSIN (this can reflect terminal input) and SYSTSPRT (this is where terminal output is sent).
Here is the JCL that would work according the information provided above:-
//MYJOB JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
//*-------------------------------------------------------------------
//RUNPROG EXEC PGM=IRXJCL,PARM=’HELLO’
//*
//* RUN OUR REXX PROGRAM CALLED HELLO
//*
//SYSEXEC DD DSN=ME.USER.EXEC,DISP=SHR
//SYSTSIN DD DUMMY
//SYSTSPRT DD SYSOUT=*
//*-------------------------------------------------------------------
This method, although the simplest (by just a few lines of JCL), is the most restrictive in that it does not allow the use of
TSO/E services, such as TSO/E commands and most of the TSO/E external
functions.
However, as IRXJCL is a Rexx processor, there is no requirement to let
TSO/E know that it is a Rexx program (the first line must include
REXX).
Method 2 - Run the program from a TSO/E environment
This entails running one of the TSO/E batch processing programs IKJEFT01 is used in this example. Alternatives are IKJEFT1A and IKJEFT1B. TSO/E services and commands can be used via this method (e.g. note at end of this method using the TIME command)
Comprehensive information about the differences between the programs
can be found at Writing JCL for command
execution
The JCL for IKJEFT01 is similar to that used in Method 1. An additional DDNAME SYSPROC can be coded. SYSPROC is the DDNAME where CLISTS would be located; You can have Rexx programs found here in addition to SYSEXEC (which isn't required, a suggestion is that both are coded and that SYSEXEC is used for Rexx programs and SYSPROC is used for CLISTS).
It's the requirement that Rexx is on the first line that
differentiates a Rexx program from a CLIST (by the TSO/E processor). Thus, if the Rexx program is found/located via SYSEXEC, if I recall correctly, this negates the requirement).
Another suggestion is to always include REXX in the first line of a Rexx program>
The EXEC statement invokes the IKJEFT01 program instead of IRXJCL. PARM can be used to specify the first command (and therefore our HELLO program). However, as for foreground, you can specify this via the terminal i.e. the SYSTSIN DDNAME.
Here is some JCL that would work for the second method; noting that the HELLO program is invoked via the SYSTSIN DDNAME as instream data :-
//MYJOB JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
//*-------------------------------------------------------------------
//RUNPROG EXEC PGM=IKJEFT01
//*
//* RUN OUR REXX PROGRAM CALLED HELLO IN A TSO/E ENVIRONMENT
//*
//SYSPROC DD DSN=ME.USER.CLIST,DISP=SHR
//SYSEXEC DD DSN=ME.USER.EXEC,DISP=SHR
//SYSTSIN DD *
HELLO
//SYSTSPRT DD SYSOUT=*
//*-------------------------------------------------------------------
If, for example, the following were used (i.e. added TIME as another
line to SYSTSIN) then the TSO/E TIME command would be run (which would
cause the time to be displayed to SYSTSPRT).
//SYSTSIN DD *
HELLO
TIME
Method 3 - Run the program in an ISPF environment
This method uses the IKJEFT01 program (see method 2 for IKJEFT1A/B alternatives). However, it then uses the ISPSTART command to run the program in an ISPF environment; enabling the use of ISPF services (e.g file tailoring (skeletons) ISPF tables etc).
An ISPF environment has additional requirements in that ISPF libraries need to be allocated in order to start an ISPF environment. At a minimum have the supplied ISPF libraries allocated to ddnames ISPPLIB (ISPF Panels), ISPMLIB (ISPF Messages) & ISPTLIB (ISPF Tables). ISPPROF is where ISPF keeps some profile data for the session, so a temporary store is sufficient (UNIT=SYSDA is often available if not always).
Note you would likely allocate, at a minimum, the installations system
libraries (the TSO/E command LISTA can likely be used to determine
these from a foreground session). Alternately, ask you local friendly system programmers. In the following they are SYS1.ISPPLIB, SYS1.ISPMLIB and SYS1.ISPTLIB.
Here is some JCL that would work for the 3rd method. Note that HELLO is passed as a parameter to the ISPSTART command.
//MYJOB JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
//*-------------------------------------------------------------------
//RUNPROG EXEC PGM=IKJEFT01
//*
//* RUN OUR REXX PROGRAM HELLO IN A TSO/E/ISPF ENVIRONMENT
//*
//SYSPROC DD DSN=ME.USER.CLIST,DISP=SHR
//SYSEXEC DD DSN=ME.USER.EXEC,DISP=SHR
//ISPPLIB DD DSN=SYS1.ISPPLIB,DISP=SHR
//ISPMLIB DD DSN=SYS1.ISPMLIB,DISP=SHR
//ISPTLIB DD DSN=SYS1.ISPTLIB,DISP=SHR
//ISPPROF DD UNIT=SYSDA,SPACE=(CYL,(10,1)),
// RECFM=FB,LRECL=80,BLKSIZE=0
//SYSTSIN DD *
ISPSTART CMD(HELLO)
//SYSTSPRT DD SYSOUT=*
//*-------------------------------------------------------------------
Note this is not a fully comprehensive, it is an overview that should
suffice for getting started with running Rexx programs in batch.
Additional comments to the above answer.. The below technote may be helpful if you wish to run your REXX exec using ISPF services...
http://www.ibm.com/support/docview.wss?uid=swg21023990
Make sure that the ISPPROF file is concatenated as the first file in ISPTLIB. The example uses a temporary file that will be unique to the job. If the REXX exec does table services you may need an ISPTABL DD. I would suggest using the same file for ISPPROF and ISPTABL and concatenate it first in ISPTLIB. This can be a permanent file if the table needs to be save, however it should not be in use by other jobs or TSO users so as to avoid enqueue errors.
As the previous update stated his answers suffice for the simple REXX exec.
Yet more additional comments to the answer by MikeT...
Suppose you want your JCL to be self-contained: you want to include a REXX exec as an in-stream data set in the JCL, rather than referring to a REXX exec stored in a PDS member.
Here's the "trick" (for IRXJCL; I haven't tested this trick with other programs): specify a single null (X'00') byte as the value of the PARM attribute of the EXEC statement.
To specify the null byte, use the z/OS ISPF editor with HEX ON:
//REXX EXEC PGM=IRXJCL,PARM=' '
66DCEE44444CECC4DCD7CDEDCD6DCDD7707
1195770000057530774E997133B7194ED0D
For example, if you entered PARM=' ' with a space as the value, overtype the 4 of the hex value of that space with a 0.
Here's an example job step containing an in-stream REXX exec that processes the output from a previous step in the same job:
//* PARM value is a single X'00' byte
//REXX EXEC PGM=IRXJCL,PARM=' '
//SYSEXEC DD DATA,DLM=$$
/*
Transposes first line of input CSV into one record per field
Reads CSV from ddname SYSTSIN.
Writes output to ddname SYSTSPRT.
*/
columnSeparator = ","
/* Get the header row */
parse pull row
/* Get column names */
do i = 1 until row = ""
parse value row with columnName "," row
say columnName
end
exit 0
$$
//SYSTSIN DD DSN=&&CSV,DISP=OLD
//SYSTSPRT DD SYSOUT=*
Notes:
In this context, the first line of the REXX exec does not need to contain the string "REXX"
DLM=$$ enables you to use REXX comment syntax (/*) without prematurely ending the in-stream data set
&&CSV refers to a CSV file created by a previous job step (not shown)
I use this "in-stream REXX" technique mostly for ad hoc execs to transform the output of a batch program into what I really want. This technique can be useful for demonstrations and quickly bouncing ideas around; other developers can view the REXX code in situ in the JCL in SDSF output, tweak it, and then submit the tweaked version.

Sun Grid Engine resubmit job stuck in 'Rq' state

I have what I hope is a pretty simple question, but I'm not super familiar with Sun Grid, so I've been having trouble finding the answer. I am currently submitting jobs to a grid using a bash submission script that generates a command and then executes it. I have read online that if a sun grid job exits with a code of 99, it gets re-submitted to the grid. I have successfully written my bash script to do this:
[code to generate command, stores in $command]
$command
STATUS=$?
if [[ $STATUS -ne 0 ]]; then
exit 99
fi
exit 0
When I submit this job to the grid with a command that I know has a non-zero exit status, the job does indeed appear to be resubmitted, however the scheduler never sends it to another host, instead it just remains stuck in the queue with the status "Rq":
job-ID prior name user state submit/start at queue slots ja-task-ID
-----------------------------------------------------------------------------------------------------------------
2150015 0.55500 GridJob.sh my_user Rq 04/08/2013 17:49:00 1
I have a feeling that this is something simple in the config options for the queue, but I haven't been able to find anything googling. I've tried submitting this job with the qsub -r y option, but that doesn't seem to change anything.
Thanks!
Rescheduled jobs will only get run in queues that have their rerun attribute (FALSE by default) set to TRUE, so check your queue configuration (qconf -mq myqueue). Without this, your job remains in the rescheduled-pending state indefinitely because it has nowhere to go.
IIRC, submitting jobs with qsub -r yes only qualifies them for automatic rescheduling in the event of an exec node crash, and that exiting with status 99 should trigger a reschedule regardless.

rufus/scheduler every sunday

I need to schedule a script using rufus every Sunday at 9pm.
I have the following in my task_schedule.rb
require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new
scheduler.every("week") do
puts("Emailing Unverified Evidence Items Digest #{Time.now}")
ArtifactsController.email_unverified_artifacts_digest
end
Want to know what is the syntax for scheduling it every "Sunday at 9pm"?
as indicated in the readme (https://github.com/jmettraux/rufus-scheduler/), rufus-scheduler understands cron strings, like in:
scheduler.cron("0 21 * * sun") do
# whatever...
end
On your OSX / GNU/Linux system, type "man 5 crontab" in a terminal to have a detailed explanation of that format.
Cheers.
(please note that rufus-scheduler's cron feature doesn't leverage the underlying system's cron daemon)