IBM Support

Scheduling Tips: Querying the Status of Work in Progress via LISTSTAT in BATCH

Question & Answer


Question

Scheduling Tips: Querying the Status of Work in Progress via LISTSTAT in BATCH

Answer

You can use the EQQYCAIN action called "LISTSTAT" to query the status
of work in progress. This can be used to find out if a batch job
has finished, abended or not finished/started yet. This can be useful
when you have critical batch (or "milestone") that has to be monitored.
.
Here's an example of JCL that can be used to run LISTSTAT:
.
//TWSQUERY JOB MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M
//*--------------------------------------------------------------*
//PIFCMD EXEC PGM=EQQYCAIN,PARM=TWSC
//EQQMLIB DD DISP=SHR,DSN=PROD.INST.SEQQMSG0
//BATCHL DD SYSOUT=*
//OI DD SYSOUT=*
//AD DD SYSOUT=*
//CPOC DD SYSOUT=*
//CPOP DD SYSOUT=*
//DATAFI DD SYSOUT=*
//EXPORTAD DD SYSOUT=*
//EXPORTOI DD SYSOUT=*
//ERREUR DD SYSOUT=*
//EQQMLOG DD SYSOUT=*
//EQQDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
ACTION=OPTIONS,BL=N,BLPRT=N,LTP=N;
ACTION=LISTSTAT,RESOURCE=CPOPCOM,
ADID=MYCRITICALAPP,
OPNO=020,
IA=0711122300.
//*IA=YYMMDDHHMM.
//* LISTSTAT RETURN CODES
//* ---------------
//* 0 INSTRUCTION SUCCESSFULLY PROCESSED
//* 4 RESOURCE NOT FOUND OR USER ID HAS NO RACF AUTHORIZATION
//* 8 INSTRUCTION FAILED AND A ERROR MESSAGE IS WRITTEN TO EQQMLOG
//* 31 OCCURRENCE STATUS C (COMPLETED)
//* 32 OCCURRENCE STATUS D (DELETED)
//* 33 OCCURRENCE STATUS E (ENDED IN ERROR)
//* 34 OCCURRENCE STATUS P (PROCESSOR PENDING)
//* 35 OCCURRENCE STATUS S (STARTED)
//* 36 OCCURRENCE STATUS U (UNDECIDED)
//* 37 OCCURRENCE STATUS W (NO STARTED OPERATIONS)
//* 40 OPERATION STATUS *
//* 41 OPERATION STATUS A (WAITING FOR INPUT TO ARRIVE)
//* 42 OPERATION STATUS R (READY)
//* 43 OPERATION STATUS S (STARTED)
//* 44 OPERATION STATUS C (COMPLETED)
//* 45 OPERATION STATUS D (DELETED)
//* 46 OPERATION STATUS I (INTERRUPTED)
//* 47 OPERATION STATUS E (ENDED IN ERROR)
//* 48 OPERATION STATUS W (WAITING FOR A PREDECESSOR)
//* 49 OPERATION STATUS U (UNDECIDED)
//* >49 REFER TO RETURN CODES ON PAGE 111 OF PROGRAM INTERFACES
//*
//* LISTSTAT information:
//* publib.boulder.ibm.com/tividd/td/TWS/SC32-1266-00/en_US/HTML
//* /Eqqn1mst154.htm
//*
//* LISTSTAT Return Codes:
//* publib.boulder.ibm.com/tividd/td/TWS/SC32-1266-00/en_US/HTML
//* /Eqqn1mst154.htm#retcode
//*
//* JCL Usage:
//* -Update the EQQMLIB as per your installation.
//* -Update the PARM on the EXEC PGM=EQQYCAIN line to your controller
//* subsystem's name.
//* -If neccessary, add a STEPLIB like
//* //STEPLIB DD DISP=SHR,DSN=PROD.INST.SEQQLMD0
.
This is the example’s output:
.
SDSF OUTPUT DISPLAY TWSQUERY JOB07447 DSID 2 LINE 0 COLUMNS 02- 81
COMMAND INPUT ===> SCROLL ===> CSR
*********************** TOP OF DATA **********************
J E S 2 J O B L O G -- S Y S T E M T I V -- N O D

16.30.21 JOB07447 ---- MONDAY, 12 NOV 2007 ----
16.30.21 JOB07447 IRR010I USERID MFUSER IS ASSIGNED TO THIS JOB.
16.30.21 JOB07447 ICH70001I MFUSER LAST ACCESS AT 16:22:20 ON MONDAY, NOVEMBE
16.30.21 JOB07447 $HASP373 TWSQUERY STARTED - INIT 1 - CLASS A - SYS TIV
16.30.21 JOB07447 IEF403I TWSQUERY - STARTED - TIME=16.30.21
16.30.21 JOB07447 EQQYCAIN:PIF INTERFACE INIT OPC=TWSC ,RC=00
16.30.21 JOB07447 EQQYCOPT:OPTIONS RC=00
16.30.21 JOB07447 EQQYCAIN:OPTIONS RC=0000
16.30.21 JOB07447 EQQYCLC2:ACTION=LISTSTAT,RESOURCE= CPOPCOM
16.30.21 JOB07447 EQQYCLC2:LISTSTAT CPOPCOM MYAPP1 RC=47
16.30.21 JOB07447 EQQYCAIN:LISTSTAT CPOPCOM RC=0047
16.30.21 JOB07447 EQQYCAIN:PIF INTERFACE TERM OPC=TWSC ,RC=00
16.30.21 JOB07447 - --TIMINGS (MINS.)--
16.30.21 JOB07447 -JOBNAME STEPNAME PROCSTEP RC EXCP CPU SRB CLOCK
16.30.21 JOB07447 -TWSQUERY PIFCMD 47 149 .00 .00 .00
16.30.21 JOB07447 IEF404I TWSQUERY - ENDED - TIME=16.30.21
16.30.21 JOB07447 -TWSQUERY ENDED. NAME- TOTAL CPU TIME=
16.30.21 JOB07447 $HASP395 TWSQUERY ENDED
.
You can then add another step that is dependant on the return code of
this step to perform additional funtions like bypassing the job,
adding a new job, page operations or whatever recovery function you require.
For example:
.
//MILESTN JOB MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M
//*--------------------------------------------------------------*
//STEP010 EXEC PGM=EQQYCAIN,PARM=TWSC
//EQQMLIB DD DISP=SHR,DSN=PROD.INST.SEQQMSG0
//BATCHL DD SYSOUT=*
//OI DD SYSOUT=*
//AD DD SYSOUT=*
//CPOC DD SYSOUT=*
//CPOP DD SYSOUT=*
//DATAFI DD SYSOUT=*
//EXPORTAD DD SYSOUT=*
//EXPORTOI DD SYSOUT=*
//ERREUR DD SYSOUT=*
//EQQMLOG DD SYSOUT=*
//EQQDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
ACTION=OPTIONS,BL=N,BLPRT=N,LTP=N;
ACTION=LISTSTAT,RESOURCE=CPOPCOM,
ADID=MYCRITICALAPP,
OPNO=021,
IA=0711122300.
//*--------------------------------------------------------------*
//* Run this job at 06:00 to check status of MYCRITICALAPP(021)
//* and if it's not complete, abend MILESTN to notify Operations
//*--------------------------------------------------------------*
//CHEK010 IF (STEP010.RC ¬= 31) AND (STEP010.RC ¬= 44) THEN
//CHEK01A EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUT2 DD SYSOUT=(A,SMTP)
//SYSUT1 DD *
HELO SMTP
MAIL FROM: <my.mainframe@some-domain.com>
RCPT TO: <operations@some-domain.com>
DATA
FROM: My Mainframe
TO: Operations
Subject: Critical Batch MYCRITICALAPP(021) not complete!
BOUNDARY: --MYEMAILBOUNDRY
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="--MYEMAILBOUNDRY";
----MYEMAILBOUNDRY
CONTENT-TYPE: TEXT/HTML; CHARSET=US-ASCII;
CONTENT-TRANSFER_ENCODING: 7BIT;
<br>
Hello Operations. There has been a problem with application
<span style="font-size:large; font-weight:bold">
MYCRITICALAPP </span> operation 021.
<br>
This means that a critical milestone in batch has failed.
<br>
Please investigate why MYCRITICALAPP(021) is not complete.
//*--------------------------
//CHEK01B EXEC PGM=EQQRETWM,PARM='WT00,UA222'
//STEPLIB DD DISP=SHR,DSN=PROD.INST.SEQQLMD0
//SYSPRINT DD SYSOUT=*
//CHEK010 ENDIF
//*--------------------------------------------------------------*
.
In the above example,
STEP010 checks the status of MYCRITICALAPP
CHEK010 checks the return code of STEP010
CHEK01A is an SMTP EMAIL to a group about the failure
CHEK01B will abend the job with a user abend code of 222.
(Of course, for the email to work, the mainframe has to be setup for SMTP)
.
EQQRETWM is part of TWS and can be used to produce any type of abend.
Parm UA222 is used to “simulate” a user abend 222, which the
author has decided to use to help identify these type of abends
as this code is dissimilar to normal abend codes.
Parm WT00 is a parm that can be used to “sleep” the job for a specific
amount of time prior to abending. The abend code is optional
which means that this program can also be used to sleep.

LISTSTAT.htm

[{"Product":{"code":"HWQQQ","label":"IBM Workload Scheduler for z\/OS"},"Business Unit":{"code":"","label":""},"Component":"Not Applicable","Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"All Versions","Edition":"Edition Independent"}]

Document Information

Modified date:
17 June 2018

UID

swg21288807