IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

FIND and REPLACE


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gayathrinag

New User


Joined: 16 Oct 2008
Posts: 37
Location: chennai

PostPosted: Wed May 18, 2011 12:23 pm
Reply with quote

Hi,

I have the below requirement.
Input
10||20|||||20
11||20
Output should be
10|SPACES|20|SPACES|SPACES|SPACES|SPACES|20
11|SPACES|20

Wherever it find the || symbols i need to replace with |SPACES|. I have tried FINDREP command.

OPTION COPY
INREC IFTHEN=(WHEN=INIT,
FINDREP=(IN=C'|||',OUT=C'|SPACES|SPACES|')),
IFTHEN=(WHEN=INIT,
FINDREP=(IN=C'||',OUT=C'|SPACES|'))

The above sort card works for the below input.
10||20||||20
11||20

If i have 10||20|||||20 this sort card is not working as expected. Any could help me this.

Thanks
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1753
Location: Tirupur, India

PostPosted: Wed May 18, 2011 12:36 pm
Reply with quote

Hello you could try,

Code:
  OPTION COPY                               
  INREC FINDREP=(IN=C'||',OUT=C'|SPACES|') 
  OUTREC FINDREP=(IN=C'||',OUT=C'|SPACES|')


Works for the example shown above,
Partially tested.

Hope it helps.
Back to top
View user's profile Send private message
gayathrinag

New User


Joined: 16 Oct 2008
Posts: 37
Location: chennai

PostPosted: Wed May 18, 2011 12:38 pm
Reply with quote

Hey Vasanth,

That worked fine.

Thanks icon_smile.gif
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1753
Location: Tirupur, India

PostPosted: Wed May 18, 2011 12:49 pm
Reply with quote

Glad to hear that it satisfies the requirement. icon_smile.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 18, 2011 4:36 pm
Reply with quote

Or..
Code:

//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,                                     
        FINDREP=(IN=C'||',OUT=C'|SPACES|',OVERRUN=TRUNC)),     
        IFTHEN=(WHEN=INIT,                                     
        FINDREP=(IN=C'||',OUT=C'|SPACES|',OVERRUN=TRUNC))       
/*                                                             
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6965
Location: porcelain throne

PostPosted: Thu May 19, 2011 1:36 pm
Reply with quote

sorry, on vacation this week and do not have access to mainframe.

question:

if it requires 2 IFTHEN's ....for 10||20|||||20
would you need additional for 10||20||||||20
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1217
Location: Dublin, Ireland

PostPosted: Thu May 19, 2011 1:46 pm
Reply with quote

Quote:
question:

if it requires 2 IFTHEN's ....for 10||20|||||20
would you need additional for 10||20||||||20


Would INREC IFTHEN= with HIT=NEXT address this?

Garry.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1753
Location: Tirupur, India

PostPosted: Thu May 19, 2011 1:57 pm
Reply with quote

Hello,
Quote:
would you need additional for 10||20||||||20

Code:
  INREC FINDREP=(IN=C'||',OUT=C'|SPACES|')
  OUTREC FINDREP=(IN=C'||',OUT=C'|SPACES|')
&
  INREC IFTHEN=(WHEN=INIT,                                     
        FINDREP=(IN=C'||',OUT=C'|SPACES|',OVERRUN=TRUNC)),     
        IFTHEN=(WHEN=INIT,                                     
        FINDREP=(IN=C'||',OUT=C'|SPACES|',OVERRUN=TRUNC))


Both work fine for any number of ||'s

DFSORT should be called more as DFSMART icon_biggrin.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6965
Location: porcelain throne

PostPosted: Thu May 19, 2011 2:34 pm
Reply with quote

thx Vasanth.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu May 19, 2011 3:44 pm
Reply with quote

Quote:
Would INREC IFTHEN= with HIT=NEXT address this?


Garry .... HIT=NEXT is not required for WHEN=INIT clause ... icon_smile.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu May 19, 2011 10:30 pm
Reply with quote

Quote:
HIT=NEXT is not required for WHEN=INIT clause


Right. HIT=NEXT is used for WHEN=INIT and WHEN=GROUP automatically (that is, the clause is always processed). WHEN=INIT and WHEN=GROUP clauses must precede any other clauses.

Quote:
DFSORT should be called more as DFSMART


What a nice thing to say. icon_smile.gif icon_cool.gif
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri May 20, 2011 4:30 am
Reply with quote

Hi,

Quote:
Gerry .... HIT=NEXT is not required for WHEN=INIT clause ...


This reminds me of home, the wife blames me for things I haven't even uttered. icon_lol.gif


Gerry
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri May 20, 2011 4:35 am
Reply with quote

Ah, Garry, not Gerry ... corrected.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri May 20, 2011 3:20 pm
Reply with quote

gcicchet wrote:
Hi,

Quote:
Gerry .... HIT=NEXT is not required for WHEN=INIT clause ...


This reminds me of home, the wife blames me for things I haven't even uttered. icon_lol.gif


Gerry

My apologies Gerry..
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Compare 2 alphabets in a REXX and fin... CLIST & REXX 2
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:


Back to Top