Fixed width 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
krisna
Participant
Posts: 77
Joined: Tue Apr 08, 2008 11:33 pm

Fixed width file

Post by krisna »

Hi All,

My target is a file which contains amount columns of 22 width. 16 for integer part, 1 for decimal point, 4 for decimal digit. 1 for sign.
for example : 0000000000000000.0000, if we have -ve sign it should be -0000000000000000.0000.
My question is if it is a +ve number it should have leading space but I'm getting trailed space.
how to achieve a leading space if it is a +ve number.
Thanks in advance
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

If your source is already a string,

if left(number,1) <> '-' then ' ' : left(number,21) else number

However, if your source is a decimal, just place it in a decimal (20,4) column and use DecimalToString(). The default conversion should give you what you're looking for.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
krisna
Participant
Posts: 77
Joined: Tue Apr 08, 2008 11:33 pm

Post by krisna »

for example from source table x and y columns had values like 234.5 and -145.64 then in file it should display as
0000000000000234.5000-0000000000000145.6400
(if it is positive number it should have a leading space so that the total width will be 22 characters.)
(if it is negative number with sign i will get 22 characters).
Thanks in advance
krisna
Participant
Posts: 77
Joined: Tue Apr 08, 2008 11:33 pm

Post by krisna »

i made a mistake that using of trim with DecimalToString() function. After removing that it worked fine.
krisna
Participant
Posts: 77
Joined: Tue Apr 08, 2008 11:33 pm

Post by krisna »

Thanks jwiles
Post Reply