Author: vickey_dw
Subject: Replacing same string with different values
Posted: Wed Feb 22, 2017 10:44 pm (GMT 5.5)
Hi All,
I need help in one more sort.
My input file is below
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
I tried Like below
But its replacing all "Allcede 123" by "Allcede 777".
Can you please suggest on this.
Subject: Replacing same string with different values
Posted: Wed Feb 22, 2017 10:44 pm (GMT 5.5)
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.