Trim Issues while sending Data to Fixed length File

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
kbsuryadev
Premium Member
Premium Member
Posts: 46
Joined: Wed Jun 06, 2007 10:32 am

Trim Issues while sending Data to Fixed length File

Post by kbsuryadev »

The input Data comes as varchar(10) - TERADATA (SOURCE)
col
0000
0009508
03669
08018
08065
0003065
09620


desired output ( i used char(5)) FIXED LENGTH FILE(TARGET)
00000
09508
03669
08018
08065
03065
09620


I have tried this code
if (DSLink3.col) ='0000' Then '00000' else DSLink3.col[3,7]

When the job ran the output is as follows
08018 output comes as 018 (it should be 08018)
09620 ------- 620
08065 ------- 065
0003065 ----- 065


Any inputs on this issue is greatly appreciated.


Thank you all.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You should take the right-most 5 characters and then pad on any additional leading zeroes if the original length was less than 5. Are you certain that your 10 digit source will always fit in 5 digits without loss of significant digits?
-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 »

Code: Select all

Right(("00000" : InLink.TheValue), 5)
The inner set of parentheses is not actually necessary; I included it for clarity.
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 »

Nicely done, Sir. Forgot that you don't even need to check, just slap some on and hack away. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
kbsuryadev
Premium Member
Premium Member
Posts: 46
Joined: Wed Jun 06, 2007 10:32 am

Post by kbsuryadev »

I used EDIT METADATA PROPERTIES

%05d (float type) and field width =5 (float type)
column metadata properties.

Output SQL type is smallint
Post Reply