ereplace and fmt equivalent in parallel

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Vignesh Shanmugam
Participant
Posts: 10
Joined: Mon Feb 22, 2010 1:58 am
Location: Chennai

ereplace and fmt equivalent in parallel

Post by Vignesh Shanmugam »

Hi all,
I have requirement in which ,i need to change a alphanumeric number to 10 digit number with all the alphabets replaced to "0" including "@,&,%,/" etc and preceding zero's to make it 10 digit .

(e.g):-(1). AF001234 TO 0000001234
(2). N/A TO 0000000000
(3). 1234ERTY TO 0012340000

Can anyone give me with some ideas?

Thanks
Vignesh Shanmugam
TCS
Chennai
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Convert() function is perfect for this task, in both server and parallel jobs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And then pad zeros for the parts it doesn't handle.
-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 »

It won't. For starters, there's no If in the expression, even though there are Then and Else. Second, you seem to be assuming some kind of loop through the characters in the string, which does not exist.

Set a stage variable to contain all the characters that must be converted to zero, for example svZeroChars. Create another containing the number of zero characters as there are in svZeroChars, for example svZeroes. Then use Convert() to convert these to zero and any function to pad to length. For example

Code: Select all

Right("000000000000":Convert(svZeroChars, svZeroes, InLink.TheString), 12)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Vignesh Shanmugam
Participant
Posts: 10
Joined: Mon Feb 22, 2010 1:58 am
Location: Chennai

Post by Vignesh Shanmugam »

I tried using "Convert" functions and "Str" .It worked fine guys.Thanks you
Vignesh Shanmugam
TCS
Chennai
Post Reply