z/OS DFSORT: Getting Started
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Reformatting records with FINDREP

z/OS DFSORT: Getting Started
SC23-6880-00

With the BUILD, FIELDS or OVERLAY parameter of the OUTREC statement, you reformat output records by specifying items that start at a specific position. But if you want to replace or remove data anywhere in your records, you would use the FINDREP parameter of the OUTREC statement instead.

Suppose you had input records that looked like this:
*"Goodbye John"*"Goodbye William"*"Goodbye Goodboy"*  
"Goodbye Mike""Good Dog""Goodbye Goodbye"          
You could use the following statements to replace all instances of 'Goodbye' anywhere in the input records with 'Bye'.
  OPTION COPY
  OUTREC FINDREP=(IN=C'Goodbye',OUT=C'Bye')

FINDREP indicates that you want to do a find and replace operation. IN identifies the constant you are looking for (the "find" constant) and OUT identifies the constant you want instead (the "replace" constant).

The output records produced by this OUTREC statement are:
*"Bye John"*"Bye William"*"Bye Goodboy"*   
"Bye Mike""Good Dog""Bye Bye"
You can use OUT=C'' (null constant) to remove identified constants. For example, you could use the following statements to remove 'bye' anywhere in the input records:
  OPTION COPY
  OUTREC FINDREP=(IN=C'bye',OUT=C'')         
The results produced for this OUTREC statement using the input records shown previously are:
*"Good John"*"Good William"*"Good Goodboy"*  
"Good Mike""Good Dog""Good Good"
You could use the following statements to change 'William' to 'Bill', 'Mike' to 'Michael', 'Dog' to 'Beagle' and '*' to '#' anywhere in the input records:
  OPTION COPY                                 
  OUTREC FINDREP=(INOUT=(C'William',C'Bill',  
    C'Mike',C'Michael',C'Dog',C'Beagle',C'*',C'#'))

INOUT identifies pairs of find and replace constants.

The results produced for this OUTREC statement using the input records shown previously are:
#"Goodbye John"#"Goodbye Bill"#"Goodbye Goodboy"#  
"Goodbye Michael""Good Beagle""Goodbye Goodbye"

For complete details on find and replace, see z/OS DFSORT Application Programming Guide.

So far
Now you know how to use the FINDREP parameter of the OUTREC statement to replace or remove data anywhere in your records. Keep in mind that you can use all of these reformatting features with the FINDREP parameter of the INREC statement and OUTFIL statement, as well as with the OUTREC statement. Next, you will learn how to use IFTHEN clauses with the OUTREC statement to reformat different records in different ways.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014