DFSORT OUTREC Reformatting with OVERLAY

DFSORT OUTREC: squeezing Data DFSORT OUTREC: Extending with OVERLAY

Advertisements


The reformatted output record one item at a time can be built with the BUILD or FIELDS parameter of the OUTREC statement.

The OVERLAY parameter of theOUTREC statement used to change one or a few items.


Syntax:

OPTION COPY
OUTREC OVERLAY=(Starting position of field1 in o/p file,
		Starting position of field1 in i/p file, Length of field1,overlay operation,…)

Name Description
Starting position of field1 in o/p fileSpecifies field1 starting position in the output file after sorting.
Starting position of field1 in i/p file Specifies field1 starting position in the input file after sorting.
Length of feild1Field1 physical length in input file.
Overlay operationSpecifies the overlay operation

Example: -

Overlay dept with DEPT in all rows and multiply marks with 10 and save the result in the same place.


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      OPTION COPY                                                        
002420      OUTREC OVERLAY=(30:30,4,TRAN=LTOU,                                 
002430                     45:45,3,ZD,MUL,+10,TO=ZD,LENGTH=4)                  
003500 /*                                                                      
****** **************************** Bottom of Data ****************************

Output:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* TOP OF DATA **********************************
00001     student1           DEPT1          5600                                
00003     student3           DEPT2          5200                                
00004     student4           DEPT1          5400                                
00005     student5           DEPT2          5000                                
00002     student2           DEPT3          5100                                
******************************** BOTTOM OF DATA ********************************

Explaining Solution:

  1. OUTREC OVERLAY=(30:30,4,TRAN=LTOU,..) - Converts the data lower to upper from 30th position of length 4 and writes to output from 30th position.
  2. OUTREC OVERLAY=(..,45:45,3,ZD,MUL,+10,TO=ZD,LENGTH=4) - the data from 45th byte multiplies with 10 and writes the result to output of the length 4 from 45th position.

DFSORT OUTREC: squeezing Data DFSORT OUTREC: Extending with OVERLAY

Advertisements