format string

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

format string

Post by sainath »

hi
I want to take last 10 char from a input string and add 00000 before it to make 15 character length.i just appendbed 00000:input column.is there any better way.
thks
sai
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Post by meena »

Hi Sai,
You can write a stage varaible for this. There are fuctions avaible in the tranformer. Use the "substr" function to extract the wanted string from the input stream and use the fmt to pad the string with the zero's and can make the total length 15. Hope this helps you. Even I am new to DS. Try this

Meena
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You can use the derivation fmt(right(In.Column,10):"00000","15'0'R") to do what you asked.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Try just fmt(right(In.Column,10),"15'0'R") as it looks like Arnd misunderstood the 'tacking on five zeroes' part.

Well, one of the two of us did. :wink:
-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 »

If Sainath has ten characters (guaranteed) from the input stream, then concatenation ("00000" : InLink.C10column) is the most efficient algorithm.
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 »

Agreed, but the FMT solution seems... better. At least from an educational standpoint. :wink:
-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 »

For some folks "performance" (whatever that means) is the primary goal. It's always beneficial to know the most efficient techniques, particularly for large to huge data volumes.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply