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

Replacing same string with different values


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

New User


Joined: 10 Jun 2015
Posts: 51
Location: India

PostPosted: Wed Feb 22, 2017 10:44 pm
Reply with quote

Hi All,

I need help in one more sort.

My input file is below

Code:
Re Insu 123
Re Insu 456
Allcede 123
Allcede 123
Allcede 123
Allcede 123
Allcede 123
Encompa 569
Encompa 458


I want to replace the 1st occurence of "Allcede 123" by "Allcede 777",2nd by "Allcede 666" ,3rd occurence by "Allcede 555",4th occurence by "Allcede 444" and 5th occurence by "Allcede 222"".All rest records should be same.

So my output File should be

Code:
Re Insu 123
Re Insu 456
Allcede 777
Allcede 666
Allcede 555
Allcede 444
Allcede 222
Encompa 569
Encompa 458


I tried Like below

Code:
Sort fields=copy
INREC IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'777')),
      IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'666')),
      IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'555')),
      IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'444')),
      IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'222'))


But its replacing all "Allcede 123" by "Allcede 777".

Can you please suggest on this.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Feb 22, 2017 11:16 pm
Reply with quote

Will your input have random occurrences of 'Allcede 123' , counting more than 5? If yes, what would you like to see in the output, especially for the 6th or later.

Something like...

Code:
--some data
--some data
Allcede 123
Allcede 123
--some data
--some data
Allcede 123
--again some more data
Allcede 123
Allcede 123
Allcede 123
Allcede 123
Back to top
View user's profile Send private message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 51
Location: India

PostPosted: Wed Feb 22, 2017 11:23 pm
Reply with quote

Quote:
Will your input have random occurrences of 'Allcede 123' , counting more than 5? If yes, what would you like to see in the output, especially for the 6th or later.


No.Input file is exactly same as i have given in earlier post.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 22, 2017 11:40 pm
Reply with quote

On INREC use IFTHEN=(WHEN=(logicalexpression to identify your 'Allcede 123' and temporarily extend the records with a SEQNUM.

Then five IFTHEN=(WHEN=( to rest for the sequence number allocated being 1, 2, 3, 4, 5 with OVERLAY to make the change.

Use IFOUTLEN to return records to original size (since the extension is not needed once it has been used).
Back to top
View user's profile Send private message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 51
Location: India

PostPosted: Thu Feb 23, 2017 12:02 am
Reply with quote

Hi Bill

Thanks for the suggestion.

But i have confusion here after adding sequence number for every occurrence of "Allcede 123" .How to replace it by "Allcede 777","Allcede 666","Allcede 555","Allcede 444","Allcede 222"
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 23, 2017 1:10 am
Reply with quote

If sequence number is one, you put the first value, if sequence number is two, you put the second, if sequence number is three, you put the third, and so on.
Back to top
View user's profile Send private message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 51
Location: India

PostPosted: Fri Feb 24, 2017 11:49 pm
Reply with quote

Thank You Bill !!!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top