Page 1 of 1

replace

Posted: Tue Aug 22, 2006 8:59 am
by adams06
Hi,

how to replace a leading prefix with 'xyz'

Thanks in advance

Posted: Tue Aug 22, 2006 9:02 am
by chulett
:idea: You might want to give just a wee bit more detail... and an example.

Re: replace

Posted: Tue Aug 22, 2006 9:07 am
by prabu
adams06 wrote:Hi,

how to replace a leading prefix with 'xyz'

Thanks in advance

Please do the follwing steps in the same order

1) Open your online datastage help
2)Goto Search
type

Code: Select all

string functions
:wink: :wink:

try to use one or more of the functions listed to achieve your result

replace

Posted: Tue Aug 22, 2006 9:10 am
by adams06
chulett wrote::idea: You might want to give just a wee bit more detail... and an example.

Here are the examples

B-CDE PASS "NEED TO REPLACE B WITH XYZ"

A-HJU PASS "NEED TO REPLACE A WITH XYZ"

AHJU PASS "NEED TO REPLACE A WITH XYZ"

Thanks in Advance.

Posted: Tue Aug 22, 2006 9:20 am
by kcbland
If you mean replace everything in front of the first "-" with something else. I think you have a few choices. One is using the FIELD function. The other is to use the INDEX function and substring notation.

Write a DS Function and test both of these:

Code: Select all

Ans="XYZ":"-":FIELD(Arg1,"-",2,999)
or

Code: Select all

Ans="XYZ":Arg1[INDEX(Arg1,"-",1),LEN(Arg1)]

Posted: Tue Aug 22, 2006 9:44 am
by chulett
And if you mean replace the first character with 'XYZ' - substring.

Posted: Tue Aug 22, 2006 2:56 pm
by urshit_1983
Try to make a small sub-routine like:


in1=Arg1
l=len(in)
new=right(in,l-1)
in2="XYZ"
Ans=cats(in2,new)

Posted: Tue Aug 22, 2006 3:02 pm
by urshit_1983
Sorry the variable names ....

in1=Arg1
l=len(in1)
new=right(in1,l-1)
in2="XYZ"
Ans=cats(in2,new)

Now its ok.

Posted: Wed Aug 23, 2006 12:59 am
by ameyvaidya
the following can save you a routine call

You can use the following derivation in a transformer Stage variable or output Derivation

Code: Select all

"xyz" : in.col[len(in.col)-1]

Posted: Wed Aug 23, 2006 3:00 am
by ArndW
Even shorted derivation:

Code: Select all

"xyz":In.Col[2,99999]

Posted: Wed Aug 23, 2006 7:07 am
by chulett
Or:

Code: Select all

"xyz":In.Col[2,Len(In.Col2)]
:wink: