mainframezosjcl

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(*)
...
//

Solution

  • 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