Page 1 of 1

Find and Replace @ Diff positions.

Posted: Fri Dec 02, 2011 11:11 pm
by hparthas
Hi All,

Can anyone help me with my requirement.

My output file contains some incorrect / invalid character I know its HEX values. But I need to replace these HEX values in 2 different ranges.

1) Input file (Sortin) is LRECL 128
2) RECFM = fb
3) First range is from 10-26
4) Second Range is from 70-86

If I find these hex values only between these 2 ranges I need to replace with spaces.

Invalid HEX are X'D5', X'4B', X'2B'. I need to replace this with X'40'

I know we can use FINDREP to change these one / more HEX values to spaces, I tried it and it worked, but found that I have these invalid values in other ranges and those also got replaced, since I dont want to change those values. I want to change only the values between 10-16 and 70-86.

Any help would be great.

Best Regards,
Harikrishnan

Posted: Fri Dec 02, 2011 11:41 pm
by Frank Yaeger
You can use STARTPOS=x and ENDPOS=y with FINDREP to limit the columns it searches. Something like:

Code: Select all

  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=10,ENDPOS=16,
    IN=(X'D5',X'4B',X'2B'),OUT=X'40'),HIT=NEXT),
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=70,ENDPOS=86,
    IN=(X'D5',X'4B',X'2B'),OUT=X'40'))