OUTREC Justifying Data Example


Scenario - Align the data in first 29 bytes to LEFT and replace () with <>.

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
  (student1)                 dept1          560       01012015
     (student2)              dept2          520       03032015
          (student3)         dept1          540       06022015
(student4)                   dept2          500       09202015
       (student5)            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.INPUT03,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 *
     OPTION COPY
     OUTREC FIELDS=(1,29,JFY=(SHIFT=LEFT,PREBLANK=C'()',
                    LEAD=C'<',TRAIL=C'>'),30,30)
/*

Output -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
<student1>                   dept1          560       01012
<student2>                   dept2          520       03032
<student3>                   dept1          540       06022
<student4>                   dept2          500       09202
<student5>                   dept3          510       05182

Explaining Example -

  1. OUTREC FIELDS=(1,29,JFY=(SHIFT=LEFT,..),..) - Justifies the data in the first 29 bytes to left.
  2. OUTREC FIELDS=(1,29,JFY=(..,PREBLANK=C'()',..),..) - blank out the ().
  3. OUTREC FIELDS=(1,29,JFY=(.., LEAD=C'<',TRAIL=C'>'),..) - adds the Cā€™<ā€™ as a lead and Cā€™>ā€™ as a trail.
  4. OUTREC FIELDS=(..,30,30) - Copies the input file data from 30th byte of length 30 copies to output as it is.