OUTREC Convert Date Example


Scenario - Convert the date from mmddccyy to ccyymmm(juliyan date).

Input File - MATEPK.SORT.INPUT01 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
00001     student1           dept1          560       01012015
00003     student3           dept2          520       03032015
00004     student4           dept1          540       06022015
00005     student5           dept2          500       09202015
00002     student2           dept3          510       05182015

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//MATEPKD  JOB (123),'MTH',NOTIFY=&SYSUID
//*
//STEP01   EXEC PGM=SORT
//SORTIN   DD DSN=MATEPK.SORT.INPUT01,DISP=SHR
//SORTOUT   DD DSN=MATEPK.MERGE.OUTPUT,
//            DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
//            SPACE=(CYL,(1,4),RLSE),
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
     SORT FIELDS=(1,5,CH,A)
     OUTREC FIELDS=(1,54,55,8,Y4W,TOJUL=Y4T)
/*

Output -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
00001     student1           dept1          560       2015001
00002     student2           dept3          510       2015138
00003     student3           dept2          520       2015062
00004     student4           dept1          540       2015153
00005     student5           dept2          500       2015263

Explaining Example -

  1. OUTREC FIELDS=(1,54,..) copies first 54 bytes of input file data to output as it is.
  2. OUTREC FIELDS=(..,55,8,Y4W,TOJUL=Y4T)- data from 55th byte of length 8 will be converted to Y4T Julian date format.

Input date 01012015 will be converted as 2015001.