OUTREC Reformatting records with FINDREP
OUTREC Reformatting records with FINDREP
The OUTREC statement can be used with FINDREP to search for specific strings or values in the records and replace them with other strings or values.
Syntax -
//SYSIN DD *
SORT FIELDS=...
OUTREC FINDREP=(IN=charset,
OUT=charset)
/*
IN=charset | Specifies source charset (the "find" string) . |
OUT=charset | Specifies new or target charset (the "replace" string). |
Examples -
Scenario1 - Replacing a specific string.
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FINDREP=(IN=C'OLD',OUT=C'NEW')
/*
Searches for the string 'OLD' in each record and replaces it with 'NEW'.
Scenario2 - Replacing a numeric value.
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FINDREP=(IN=123,OUT=456)
/*
Searches for the numeric value 123 in the record and replaces it with 456.
Scenario3 - Replacing Multiple Strings.
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FINDREP=(IN=C'OLD1',OUT=C'NEW1',IN=C'OLD2',OUT=C'NEW2')
/*
Searches for both 'OLD1' and 'OLD2' in each record and replaces them with 'NEW1' and 'NEW2', respectively.