Page 1 of 1
discarding sign byte for a decimal when writing it to a file
Posted: Thu Mar 15, 2007 11:30 am
by KishoreRaju
Hi
I am new to data stage.
when i am writing decimal onto a file its giving an extra space for the sign . it is possilbe to write without sign space.can any one tell how can we do this .
i tried below ways.
using Abs ,DecimalToDecimal functions
configuring the properties in the sequential file stage like Packed.
Thanks In Advance
Posted: Thu Mar 15, 2007 11:49 am
by DSguru2B
If you want to write to a file as Decimal it will always save a space for the sign. If you dont want that, change it to string and load it to a varchar field.
Posted: Thu Mar 15, 2007 12:05 pm
by KishoreRaju
Thanks for the quick reply.
The complete description about my senario.
input-OralceStage-->Transformer--SequentialStage(Flat file fixed width)
i have data stage job which is retrieving a decimal of size (15,2) and in the target i have to map it to (5,2).
in the transformer i created two stage variables
indecimal-->decimal(5,2)
decToCahr-->char(6).
first i am mapping source decimal to Transformer stage variable(it is doing implicit truncation if possilbe if source is bigger then its throwing an exception.
after that i am converting it to char by using the below function
DecimalToString(VarTRPCT,"fix_zero").
this is giving a string of 7 characters(one for space and one for period).
on the above i am appling a substring function to get ride of sign.
is there is any other simple way that makes my life easy.
Posted: Thu Mar 15, 2007 12:24 pm
by DSguru2B
Out of curiosity, why do you want to change the decimal field to char. Is it just becuase of the leading space. Let it be there, the space will not affect the fixed width file format.
Posted: Thu Mar 15, 2007 12:43 pm
by KishoreRaju
in the requirments i have a separate field for sign .for that reason i am removing the sign when writing the decimal value.
is there any other way that i can do ,with out doing all these conversions
Posted: Thu Mar 15, 2007 12:50 pm
by DSguru2B
No. I doubt there is any other way. Basically you will have to convert to string and then do your substrings which you already are.