Convert Function - Mulitple Characters as a set for replace

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Convert Function - Mulitple Characters as a set for replace

Post by snt_ds »

Hi,

I am trying to replace all the characters 'XX,' to '' (Empty) using the Convert function..As I underatand it replaces each character seperately and hence my output is not as expected.

I want to change "XX,XX,XX,6,XX,7" to "6,7"

Any other way to replace this entire set in one go?

Thanks,
NV
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Are you using a server job or PX job? If server job, there are functions like EReplace.. If you are using a PX job, use BASIC transformer.
Kandy
_________________
Try and Try again…You will succeed atlast!!
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

Yes I know..
But this is a PX job as reflected in the Job Type in the Post header
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Then use the BASIC transformer in your PX job and use EReplace function.
Kandy
_________________
Try and Try again…You will succeed atlast!!
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

Thanks for your Great Advice but not an Efficient one! :shock:

We figured out a solution in PX..
using Trim(Convert('XX','',ARG),',','R')

Thanks,
NV
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I believe you'll find that DSGuru2B posted a PX version of EReplace here some time back. If memory serves.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Convert works one character at a time.

That it worked for you was pure luck - all you got was each "X" converted to "A". Therefore "XX" would have been converted to "AA".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

As Ray told, convert works on one character at a time. If you are fine with using convert, then just to let you know... you can replace that convert with another trim too !!

one trimA to remove all X and another trimR to remove unwanted commas.

Or you could correct your statement to Trim(Convert('X','',ARG),',','R')
Kandy
_________________
Try and Try again…You will succeed atlast!!
Post Reply