OUTREC Inserting Sequence Numbers
OUTREC Inserting sequence numbers Example
Scenario - Generate the sequence numbers in positions 60-61 starting from 5 and increment by 5 for each record using OUTREC.
Input File - MATEPK.SORT.INPUT01 - FB file of 80 length
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 00001 student1 dept1 560 00003 student3 dept2 520 00004 student4 dept1 540 00005 student5 dept2 500 00002 student2 dept3 510
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,ZD,A)
OUTREC OVERLAY=(60:SEQNUM,2,ZD,START=5,INCR=5)
/*
Output -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 00001 student1 dept1 560 05 00002 student2 dept3 510 10 00003 student3 dept2 520 15 00004 student4 dept1 540 20 00005 student5 dept2 500 25
Explaining Example -
- SORT FIELDS=(1,5,ZD,A) - Input file will be sorted first and writes to the output.
- OUTREC OVERLAY=(60:SEQNUM,2,ZD,START=5,INCR=5) - Generates the sequence number of length 2 from 60th byte. The sequence number starts at 5 and incremented by 5 each time.