Page 1 of 1

generate zeros based on input

Posted: Thu Nov 17, 2005 5:31 pm
by DSguru2B
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.

Posted: Thu Nov 17, 2005 5:53 pm
by chulett
Check out the FMT command. It can justify and zero fill to a specific number of digits in a derivation.

Posted: Thu Nov 17, 2005 5:58 pm
by jenkinsrob
Try the following code in a Stage Variable in your transformer

Code: Select all


<Field>:Str("0", 6 - Len(<Field>))


Posted: Thu Nov 17, 2005 6:02 pm
by chulett
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.

Posted: Fri Nov 18, 2005 8:39 am
by DSguru2B
It works. Thanks guyz.