INREC
INREC
Summary
- The INREC statement can reformat the records before sorting.
- The INREC statement has the same format as the OUTREC statement.
- INREC reformats the records before they are sorted.
- The SORT and SUM statements refer to the reformatted records.
- DFSORT processes the INREC statement before SORT, SUM, and OUTREC. But INCLUDE and OMIT processed before INREC statement.
- DFSORT processes the OUTFIL statements after the INREC and OUTREC statements. OUTFIL must refer to the reformatted records produced by OUTREC/INREC if specified.
- OVERFLOW can be prevented by using INREC as INREC will be processed before SUM statement execution. OVERFLOW can be prevented by INREC to pad summary fields with zeroes.
Note! OUTREC can’t prevent overflow as it processed after summarization.
Example -
Scenario - Removing the student department using INREC.
Input File - MTHUSER.SORT.INPUT01 - FB file of 80 length
----+----1----+----2---+----3----+----4---+---5---+---6---+---7---+----8
********************************* Top of Data ******************************
00001 student1 dept1 560
00003 student3 dept2 520
00004 student4 dept1 540
00005 student5 dept2 500
00002 student2 dept3 510
******************************** Bottom of Data ****************************
JCL -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card
//*
//******************************************************************
//*
//* SORT FOR OUTREC STATEMENT
//*
//******************************************************************
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,5,ZD,A)
INREC FIELDS=(1,29,45,30)
/*
**************************** Bottom of Data ************************
Output -
----+----1---+---2----+---3---+----4---+----5---+----6---+---7---+----8
********************************* TOP OF DATA ******************************
00001 student1 560
00002 student2 510
00003 student3 520
00004 student4 540
00005 student5 500
******************************** BOTTOM OF DATA ****************************
Explaining Example -
INREC FIELDS=(1,29,45,30) - Reformat the input file of length 80 to 59 bytes(1 to 29 bytes plus 45 to 75 bytes) and the same copied to output.