Tuesday, December 6, 2011

REPLACE in SORT

Did you know how to change a character to another, or string to another, using SORT ?

eg) If position 10 has got character 'x', then change it to 'y', otherwise retain the current value.

Assuming the file has got an LRECL of 80, the following SORT SYSIN card should do :

 SORT FIELDS=COPY
 OUTREC FIELDS=(1,9,10,1,CHANGE=(1,C'X',C'Y'),NOMATCH=(10,1),11,70)

(here, NOMATCH - If the 10th byte is not 'X', then retain its value.)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.