Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replacing same string with different values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 42
Location: India

PostPosted: Wed Feb 22, 2017 10:44 pm    Post subject: Replacing same string with different values
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: 2285
Location: @my desk

PostPosted: Wed Feb 22, 2017 11:16 pm    Post subject:
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: 42
Location: India

PostPosted: Wed Feb 22, 2017 11:23 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Feb 22, 2017 11:40 pm    Post subject: Reply to: Replacing same string with different values
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: 42
Location: India

PostPosted: Thu Feb 23, 2017 12:02 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Feb 23, 2017 1:10 am    Post subject: Reply to: Replacing same string with different values
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: 42
Location: India

PostPosted: Fri Feb 24, 2017 11:49 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts change string before sertan string anatol DFSORT/ICETOOL 8 Tue Aug 15, 2017 5:43 pm
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am
No new posts replacing junk with hyphen Nitin32 DFSORT/ICETOOL 10 Fri Jun 02, 2017 7:47 pm
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us