DFSORT OUTREC Reformatting with FINDREP

DFSORT OUTREC: Extending with OVERLAY DFSORT OUTREC: Reformatting with IFTHEN

Advertisements


The reformat output records by specifying items that start at a specific position can be done with the BUILD, FIELDS or OVERLAY parameter of the OUTREC statement.

But if to replace or remove data anywhere in records, the FINDREP parameter of the OUTREC statement needs to use instead.

FINDREP indicates that doing a find and replace operation.

IN identifies the constant (the "find" constant) and OUT identifies the constant (the "replace" constant).


Syntax:

OPTION COPY
OUTREC FINDREP=(IN=String/charset,OUT=String/charset)

Name Description
IN=String/charsetSpecifies string/charset that needs to find in the file.
OUT=String/charsetSpecifies new string/charset that used to replace in the file.

Example: -

Reformatting dept with DEPT using FINDREP.


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 FINDREP=(IN=C'dept',OUT=C'DEPT')                            
003500 /*                                                                      
****** **************************** Bottom of Data ****************************

Output:

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

Explaining Solution:

OUTREC FINDREP=(IN=C'dept',OUT=C'DEPT') - finds the text “dept” in the entire input file with the “DEPT” and writes to the output.


DFSORT OUTREC: Extending with OVERLAY DFSORT OUTREC: Reformatting with IFTHEN

Advertisements