String Replace.



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

String Replace.

Postby Vineet » Wed Jun 05, 2013 3:54 am

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: String Replace.

Postby skolusu » Wed Jun 05, 2013 5:14 am

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.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: String Replace.

Postby Vineet » Wed Jun 05, 2013 9:10 am

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: String Replace.

Postby BillyBoyo » Wed Jun 05, 2013 12:34 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: String Replace.

Postby skolusu » Wed Jun 05, 2013 9:30 pm

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.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post