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
DSguru2B
Charter Member
Posts: 6854 Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX
Post
by DSguru2B » Thu Nov 17, 2005 5:31 pm
I have a column where the length of the field has to be 6. if it is less than 6, i have to keep the length of the field as 6 and add zeros on the remaining field.
I am checking the length of the field by the Len() function. but how to put that many zeros in that field. Can it be done within the transformer or i need to write a routine for it.
thanks guys.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Nov 17, 2005 5:53 pm
Check out the FMT command. It can justify and zero fill to a specific number of digits in a derivation.
-craig
"You can never have too many knives" -- Logan Nine Fingers
jenkinsrob
Participant
Posts: 31 Joined: Mon Dec 01, 2003 6:24 am
Location: London
Post
by jenkinsrob » Thu Nov 17, 2005 5:58 pm
Try the following code in a Stage Variable in your transformer
Code: Select all
<Field>:Str("0", 6 - Len(<Field>))
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Nov 17, 2005 6:02 pm
Why code it when there are built in functions to do that work?
Check
this post for a couple of examples of how to use the FMT command.
-craig
"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Posts: 6854 Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX
Post
by DSguru2B » Fri Nov 18, 2005 8:39 am
It works. Thanks guyz.