Year as last qualifier of dataset in a job

Year as last qualifier of dataset in a job

I struggled a lot to figure out the approach to put year in last qualifier of datasets produced by a job. I had a requirement where the job should create the ouput files with year as the last qualifier. for eg. If the output file was ABC.OUTPUT then the job should produce ABC.OUTPUT.A2013 After some research I have figured out the solution and it is two parts.   First you will need to run the following JCL to put the current year in a parm MEMOUT, this step uses SORT utility to overlay the contents in input member MEMINP with year value of DATE1. Contents of MEMIN //SET1 SET YEAR=     //************************************************************          //*JCL TO PUT CURRENT YEAR IN MEMBER PARM USING SORT *********          //************************************************************          //STEP1    EXEC PGM=SORT                                                //SYSOUT   DD SYSOUT=*                                                  //SORTIN   DD DSN=USERID..INPUT.PDS(MEMINP),DISP=SHR                     /*                                                                      //SORTOUT  DD DSN=USERID..INPUT.PDS(MEMOUT),DISP=OLD                     //SYSIN    DD  *                                                          SORT FIELDS=COPY                                                        OUTREC OVERLAY=(1:1,16,DATE1,21:30X)                                  /*                                                                        After the above job has run the contents of MEMOUT will have the following //SET1 SET YEAR=2013 Now the following job can be run by including MEMOUT and this will append year value set in MEMOUT to the output dataset   //JOBCARD //       JCLLIB ORDER=USERID..INPUT.PDS                                 //       INCLUDE MEMBER=MEMOUT                                          //************************************************************          //*JCL TO APPEND YR AS QUALIFIER IN A FLAT FILE    ***********          //*YOU NEED TO RUN SRTYEAR JCL PRIOR TO THIS JCL   ***********          //************************************************************          //STEP1  EXEC PGM=IEFBR14                                               //DD01   DD DSN=USERID..PSFILE.A&YEAR,                                   //           SPACE=(TRK,(1,1),RLSE),                                    //       DISP=(MOD,DELETE,DELETE),UNIT=SYSDA                            //STEP2    EXEC PGM=SORT                                                //SYSOUT   DD SYSOUT=*                                                  //SORTIN   DD *                                                          TEST FILE FIRST                                                        /*                                                                      //SORTOUT  DD DSN=USERID..PSFILE.A&YEAR,                                 //           SPACE=(TRK,(1,1),RLSE),                                    //            DISP=(MOD,KEEP,KEEP),UNIT=SYSDA,                          //            DCB=(LRECL=80,RECFM=FB)                                   //SYSIN    DD  *                                                         SORT FIELDS=COPY                                                      /*                                                                                                               Â