discarding sign byte for a decimal when writing it to a 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
KishoreRaju
Participant
Posts: 5
Joined: Thu Feb 15, 2007 12:17 pm
Location: bhimavaram
Contact:

discarding sign byte for a decimal when writing it to a file

Post 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
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
KishoreRaju
Participant
Posts: 5
Joined: Thu Feb 15, 2007 12:17 pm
Location: bhimavaram
Contact:

Post 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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
KishoreRaju
Participant
Posts: 5
Joined: Thu Feb 15, 2007 12:17 pm
Location: bhimavaram
Contact:

Post 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
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply