Page 1 of 1

String Replace.

PostPosted: Wed Jun 05, 2013 3:54 am
by Vineet
Hi All,
I am having a query. I am having a Sequential File which is Pipe Delimited (|) Having LREL = 80 & Recfm=FB. I need to look for a specific String & replace with new string. Below is example & my requirement.

ABCDEFGH Store Board Hello How R U|Great To See You All In Mainframeforum|I am Having Problem with String|Need to Replace word Store Board|

Here I need to Replace the Word "Store Board" with "Giant". Issue is when I am using FIND / REPLACE Option I am able to Replace the word but O/P file is not having correct format i.e. Position of Pipe Delimiter (|) gets Disturbed. Is there a way to over come the issue i.e. Spaces can be padded. Below is Exapmple.
ABCDEFGH Store Board Hello How R U|Great To See You All In Mainframeforum|I am Having Problem with String|Need to Replace word Store Board| --> I/P String


ABCDEFGH Giant Hello How R U|Great To See You All In Mainframeforum|I am Having Problem with String|Need to Replace word Giant| --> This is the O/P I am getting (Pos. Of Pipe Delimter Changed)


Expected: Spaces to be padded.
ABCDEFGH Giant Hello How R U        |Great To See You All In Mainframeforum|I am Having Problem with String|Need to Replace word Giant          |


O/P file has same attribute as I/P file.

Rgd's

Re: String Replace.

PostPosted: Wed Jun 05, 2013 5:14 am
by skolusu
Vineet,

You need to use CODE tags to preserve the spacing. So is your input a fixed layout, ie. the "|" symbol is always at a constant position? or is it variable? if it is variable what is the problem with shifting the entire string as replacing string is smaller than the original string.

Re: String Replace.

PostPosted: Wed Jun 05, 2013 9:10 am
by Vineet
Hi Kolusu,
Thankx for reply. Position of '|' is fix in the file. Since number of Char. in String 'Giant' is Less Than number of Char. in String 'Store Board' this changes the position of '|' char. is it possible to pad SPACES so that Position of '|' is not changed.

Rgd's

Re: String Replace.

PostPosted: Wed Jun 05, 2013 12:34 pm
by BillyBoyo
Vineet, trying out your suggestion is a possibility, is it not. Whatever the results, also please consult the manuals which are available by following the link on Kolusu's signature.

Re: String Replace.

PostPosted: Wed Jun 05, 2013 9:30 pm
by skolusu
Vineet wrote:Hi Kolusu,
Thankx for reply. Position of '|' is fix in the file. Since number of Char. in String 'Giant' is Less Than number of Char. in String 'Store Board' this changes the position of '|' char. is it possible to pad SPACES so that Position of '|' is not changed.

Rgd's



Here is how you can solve the problem

1. Use INREC with FINDREP to replace 'STORE BOARD' with 'GIANT '. Pad spaces after Giant
2. Since your "|" Positions are fixed. Use SQZ with OUTREC to squeeze the blanks padded by FINDREP with a MID value of SPACE.