Dave Ford
Dave Ford

Reputation: 363

How do I write current date and time to a sequential dataset using JCL?

Using z/OS 2.4, I have a Job that runs every morning that writes the status of several Db2 tablespaces into a sequential dataset, looking for any that are in a restricted state. (see code excerpt below) This JCL has run beautifully for years.

I would like to simply add the date and time to the top of the sequential dataset (followed by a blank line) so that I can easily know the last time the Job was run.

What is the best way to accomplish that?

Thanks!

Dave

//MYUSERND  JOB (16201,CCA25,227,72575),'DSPCPYPQ',
//     CLASS=1,MSGCLASS=X,MSGLEVEL=1,REGION=32M,NOTIFY=MYUSERN,TIME=99
/*JOBPARM TIME=10,LINES=050,CARDS=0000,COPIES=01
//*----------------------------------------------
//DISDB    EXEC PGM=IKJEFT01,DYNAMNBR=20
//*----------------------------------------------
//STEPLIB   DD DISP=SHR,DSN=DB2.DBQ1.DSNA10.SDSNLOAD
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD DISP=SHR,DSN=MYUSERN.DB2.CMDOUTQ
//SYSTSIN  DD *
  DSN SYSTEM(DBQ1)
  -DISPLAY DB(DN*) SPACENAM(*) USE RESTRICT LIMIT(*)
...
//

Upvotes: 1

Views: 2151

Answers (3)

Kolusu
Kolusu

Reputation: 556

JCL does not create the time and date, it is the Utilities/Programs that create them. So here are 2 ways of creating the date and time.

Method : 1 You can the symbol conversion utility of z/OS to print the date and time

//STEP0100 EXEC PGM=EZACFSM1              
//SYSOUT   DD SYSOUT=*                    
//SYSIN    DD *                           
CURRENT DATE IS  : &LYR4.-&LMON.-&LDAY    
CURRENT TIME IS  : &LHR.:&LMIN.:&LSEC     
/*                                                                  

The sysout dd will contain the following

CURRENT DATE IS  : 2024-01-05
CURRENT TIME IS  : 11:11:36  

Method: 2 Alternatively you can use DFSORT to display the same results

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                      
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                      
  OPTION COPY                                        
  OUTFIL REMOVECC,                                   
  HEADER1=('CURRENT DATE IS  : ',DATE=(4MD-),/,      
           'CURRENT TIME IS  : ',TIME=(24:))         
/*                                                   

The SORTOUT DD will have the same information as shown above

Upvotes: 4

Hogstrom
Hogstrom

Reputation: 3761

Add the timecommand before the DSN DISPLAY command you are using.

It will display something like the following:

IKJ56650I TIME-12:54:16 PM. CPU-00:00:54 SERVICE-735770 SESSION-35:19:15 JANUARY 5,2024

It includes

  • Cumulative CPU time (from LOGON)
  • Cumulative session time (from LOGON)
  • Total service units used, which includes:
  • CPU service units - A measure of task execution time.
  • I/O service units - A measure of SMF data set activity.
  • Storage service units - A measure of the page frame usage.
  • Local time of day

If you want something more formatted then REXX is your best bet.

Upvotes: 2

Ross Cruickshank
Ross Cruickshank

Reputation: 66

Since IJKEFT01 is batch TSO, you could add the TIME command before running DSN.

If you need to parse it and reformat, you could wrap it in a REXX exec, and call that instead before DSN

Execution of a REXX exec like: /*REXX*/ say date('S') time('N');say

before DSN, would add something like

20240105 17:41:13

to the start of your SYSTSPRT output dataset.

Other formats are available - https://www.ibm.com/docs/en/zos/3.1.0?topic=functions-date

Upvotes: 3

Related Questions