Daily a number of jobs run in mainframe, i need to fetch their start and end time by some other jcl or rexx automatically, is it possible ?
-
Yes, but are you sure you really need this information? What are you going to do with it? – Bill Woodger Nov 16 '16 at 16:53
-
We have to send a report of timing of nearly 20 jobs daily. we need to automate this though JCL or REXX. – Deb Nov 16 '16 at 18:57
-
Well, the answers you have already should be sufficient. Unless you don't have a Scheduler, I'd suspect this is very easy, and you'll have to do no more than request it of the correct people. – Bill Woodger Nov 16 '16 at 19:42
-
Your question is ambiguous. It was not clear to me if you wanted to get the runtime start/end time of jobs or as others have answered the scheduler settings. Please consider changing the title of your question. – David Crayford Nov 18 '16 at 12:36
4 Answers
Yes it's possible. As @SaggingRufus indicates, your job scheduler (CA JMR, Control-M, etc.) may provide this functionality - talk to your technical staff and ask.
It's possible to do this via the Rexx interface to SDSF and then scheduling a job to execute your Rexx code. The ID under which the Rexx code executes must have authority to look at the jobs for which you wish to retrieve information. There is also a Java interface to SDSF.
Another mechanism that may be available to you is SMF, but that's not going to be an easy road unless you've also got MXG.
Talk to your technical staff and explain what you want and why, they may have already solved this problem.

- 10,237
- 1
- 28
- 39
The standard way to do what you want is to use SMF 30 records. You can do this in REXX but it will be a little bit tricky if you don't understand the format of SMF records. Your site may have a tool like SAS which will make it trivial.
- SMF 30 subtype 1 is written when a job (or any address space) starts.
- SMF 30 subtype 5 is written when a job ends.
There are several other subtype records written such as job step termination deltas. The SMF 30s contain absolutely everything you could possibly want to know about a batch job. If you just wanted to know how much elapsed or CPU time a job has taken then just read the subtype 5 and look at the performance section.
If you really must use REXX then there are products that have REXX APIs that access SMF data such as IBM Transaction Analysis Workbench for z/OS. Disclaimer: I'm one of the developers of that product.

- 571
- 1
- 3
- 10
-
It's also pretty easy to produce a job started/ended report using DF/Sort or Syncsort, one of which you are bound to have. The 2 products use (almost) the same syntax. – Steve Ives Nov 18 '16 at 10:22
-
@SteveIves That's an interesting idea. Could it work with triplets? – David Crayford Nov 18 '16 at 11:42
-
-
SMF records have a self defining section with a concept called triplets which contain offsets to other sections. Here's a good writeup on how to attempt that with REXX [Processing SMF Records Using REXX](https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.csfb200/csfb2za2137.htm). I'm not sure if that's possible with sort. – David Crayford Nov 18 '16 at 12:01
This solution will work if your site uses CA JMR
//SCANJMR JOB (11111),'JMRSCAN',
// CLASS=T,MSGCLASS=X,MSGLEVEL=(1,1),
//SCAN EXEC JMRSCAN
//JMRPRINT DD DSN=&&OUTDATASET,
// DISP=(NEW,CATLG,),
// UNIT=SYSDA,SPACE=(TRK,(20,20)),
// DCB=(LRECL=133,RECFM=FB,BLKSIZE=6118)
//JMRIN DD *
FUNCTION LIST=ALL JOBMASK=* SDATE=16/11/16
EDATE=16/11/16
/*
then all you need to do is get a count of how many records are in this file.
If not, other job schedulers may provide similar functionality.

- 1,814
- 16
- 32
-
-
-
You could add "If your site uses CA JMR then..." and "Other job schedulers may provide similar functionality." – cschneid Nov 16 '16 at 15:40
-
edited. Thanks for the suggestion, being new to the mainframe (relatively speaking) I sometimes forget that there are many system variants and that CA products are actually stock products. – SaggingRufus Nov 16 '16 at 15:44
-
The system in which work, it has **Zeke scheduler**. We manually go to the event, b6,acc command, then only we get the start and end time for job. So we need to make it automatic.. – Deb Nov 16 '16 at 18:40
Another way could be to add a simple steps to the jobs that run a Rexx program that stores the date.
These steps needn't even be in the actual production job(s) you could schedule them as jobs with the production job as a successor and then as a predecessor.
Rexx has in-built time and date functions an example of their use is:-
rc = audit('OACG22X Invoked by' userid() 'at' time() 'on' date()'.')
You could update the report data by either using a DISP of MOD or by reading it in and then rewriting it with the new record added. EXECIO being the rexx function that you'd use.
When you've run the report, this would then clear the data or perhaps cycle a GDG (create an empty +1).
The following Rexx is pretty close to what could be used (albeit quite inflated i.e. you would basically be interested in the EXECIO's and the generation of the out.1 (using the current date and time) , (this only maintains 1 record in the output)):-
/* REXX - CYCLE TAPES WITHIN A POOL FOR EMHA800W BATCH JOB */
/*--------------------------------------------------------------------*/
/* read in data from tape cycle dataset */
/*--------------------------------------------------------------------*/
"EXECIO 1 DISKR CYCTAPE (stem in. FINIS"
LastTape = SUBSTR(in.1,1,6)
If LastTape = "XXXXXX" Then NewTape = "SAP001"
Else Do
TapeNum = SUBSTR(in.1,5,2)
If DATATYPE(TapeNum,"N") Then Do
NewNum = TapeNum + 1
If Newnum > 4 Then NewNum = 1
RetCde = NewNum
Newnum = RIGHT(Newnum,2,"0")
NewTape = "SAP0"||NewNum
End
Else RetCde = 100
End
out.1 = NewTape||" "||DATE("E")||" "||TIME("N")
"EXECIO 1 DISKW CYCTAPEO (stem out. FINIS"
Say "Return Code will be "||RetCde
Return RetCde
Running Rexx via batch is detailed here How can I run my Rexx program as a batch job?.
I haven't used Zeke but from a very brief search it appears that you may be able to inspect the EMR (Event Master Record).