DFSORT INREC

DFSORT OUTREC: Inserting sequence numbers DFSORT INREC: Inserting sequence numbers

Advertisements


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.

When used with the INREC statement, SORT, SUM, and OUTREC must refer to the reformatted records from INREC.

When used with the INREC statement, INCLUDE and OMIT must refer to the original records.

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: -

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 ********************************

Job:

000100 //Jobcard 
000400 //*                                                                     
000500 //**********************************************************************
000600 //*                                                                     
000700 //* SORT FOR OUTREC STATEMENT                                           
000800 //*                                                                     
000900 //**********************************************************************
001100 //STEP01   EXEC PGM=SORT                                                
001300 //SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
001800 //SORTOUT  DD SYSOUT=*                                                  
001900 //SYSOUT   DD SYSOUT=*                                                  
002400 //SYSIN    DD *                                                         
002411      SORT FIELDS=(1,5,ZD,A)                                             
002420      INREC FIELDS=(1,29,45,30)                                          
003500 /*                                                                      
****** **************************** 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 Solution:

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.


DFSORT OUTREC: Inserting sequence numbers DFSORT INREC: Inserting sequence numbers

Advertisements