Friday, April 10, 2015

Create Dataset name dynamically using system date and time or timestamp - using EZACFSM1

Many times we face the scenario, where we are in need to create a file suffixed with today's date ,time ,ie  the system date and time. It can be done in various ways. In this post we will see how to use one utility EZACSFM1 to achieve the same. It is a good utility and accepts many parameters which can be used tactfully to achieve good results.

//JOHNEZC JOB 1,'TEST', CLASS=I,NOTIFY=&SYSUID
//STEP1        EXEC PGM=EZACSFM1
//SYSOUT DD SYSOUT=(,INTRDR)   <= submit the below job via internal reader
//SYSIN DD DATA,DLM='..'
//TTEST JOB 1,'EZACSFM1',CLASS=I,NOTIFY=&SYSUID
//STEP2        EXEC PGM=IEFBR14
//MYDATA  DD DSN=TEST.DATA.D&DAY.M&LMON ,
//                          DISP=(,CATLG,DELETE),
//                         SPACE=(CYL,(10,10),RLSE),
//                         DCB=(RECFM=FB,LRECL=10,BLKSIZE=0)
(Tested code. Runs fine)
Explanation:
We are submitting the IEFBR14 job to create the dataset  TEST.DATA.DMON.M04 via internal reader as mentioned above.
If you see, i have  kept 'D&DAY' and  'M&LMON' in blue. Just to keep our attention there. The utility EZACSFM1 substitutes the value of day and month values there which will be created dynamically. &day, &lmon are the parameters of the utility.
If we submit the job, two jobs will be submitted. The first job will submit the second job creating the dataset with IEFBR14 dynamically with the date and time parameters.

To display the values in spool in sysout, try this piece of code.We will come across more options.
<Tested code >
//STEP1     EXEC PGM=EZACFSM1      
//SYSOUT    DD  SYSOUT=*          
//SYSIN     DD  *                
&YR.-&LMON.-&LDAY
&YR./&LMON./&LDAY
DATE IS : &YR.&LMON.&LDAY
/*
//
Some more parameters which EZACFSM1 takes. There are many more.

 '&DAY'                
 '&HHMMSS'              
 '&HR'                  
 '&JOBNAME'          
'&SEC'              
'&SEQ'                
'&YYMMDD'            
Test these small piece of code.M sure, you will find it very useful!!!

No comments:

Post a Comment