adding zero into input field's data

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
ravikumarav
Participant
Posts: 1
Joined: Mon Mar 17, 2014 1:44 am

adding zero into input field's data

Post by ravikumarav »

input:
_____
Qty
2
75
1275
125

i need output like below:
-----------------------------
Qty
0002
0075
1275
0125

i have tried like below to achieve the above result

Right(Str("0",4):Qty,4)--- using trasformer stage

Could please help me any one for the above..
Thanks,
Ravi.
RAVIKUMARAV
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What output do you actually get? What is the data type of your target column?
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

See if this helps.
-craig

"You can never have too many knives" -- Logan Nine Fingers
yugee
Participant
Posts: 34
Joined: Fri Feb 04, 2011 5:54 pm

Post by yugee »

You can try below:
InputField:Str('0', 4 - len(InputField))

InputField -- is your input field
4 - length if your output column after padding the leading zeroes

--this will not work if you have declared output field as numeric.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The expression you used will work fine, provided that the target column data type is string (that is, Char or VarChar).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Reply

Post by ssnegi »

Since you want 0 before the input value :

str('0',4-len(DSLink.COL)):DSLink.COL
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Reply

Post by ray.wurlod »

ssnegi wrote:Since you want 0 before the input value :

str('0',4-len(DSLink.COL)):DSLink.COL
... which is exactly the expression that the original poster used.
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