Page 1 of 1

replace character by other

PostPosted: Wed Apr 21, 2010 1:32 pm
by pulcinella
Hello,

I have a file with lrecl = 952. I need replace the character X'25' by X'40' (value hexadecimal is 25 and i want replace with space)... I don't know which position is the character. Only know that the character must be between 13 and 925 position ( although I cant examine all position of record).

If it will help the key of file is at the first 1-12 position and It's not duplicate records

My output file must be LRECL = 952 position too. I only want replace a character by another

INPUT FILE (lrecl = 952)

0000000000001aaaaa.aaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0000000000002aaaaaaaaaa.axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0000000000025aaa.aaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

OUTPUT FILE (lrecl = 952)

0000000000001aaaaa aaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0000000000002aaaaaaaaaa axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0000000000025aaa aaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

(in my example, the character X'25' is '.' I want replace this character by space

Thank you very much

Re: replace character by other

PostPosted: Wed Apr 21, 2010 1:33 pm
by pulcinella
I find that I could use the option FINDREP but I don't know how to use it... this option is correct?

Re: replace character by other

PostPosted: Wed Apr 21, 2010 9:16 pm
by skolusu
pulicnella,

Use the following control cards

//SYSIN    DD *                       
  SORT FIELDS=COPY                     
  INREC FINDREP=(INOUT=(X'25',X'40')) 
//*

Re: replace character by other

PostPosted: Wed Apr 21, 2010 9:55 pm
by pulcinella
Great Thank you very much...

But could I make the same but replace the character between 13 and 925 position of file?.

Re: replace character by other

PostPosted: Wed Apr 21, 2010 10:19 pm
by skolusu
pulcinella,

Use the following control cards

//SYSIN    DD *                       
  SORT FIELDS=COPY                     
  INREC FINDREP=(INOUT=(X'25',X'40'),STARTPOS=13,ENDPOS=925)
//*

Re: replace character by other

PostPosted: Thu Apr 22, 2010 12:12 am
by pulcinella
Great... Thank you