Page 1 of 1

Fixed Width File

Posted: Thu Nov 30, 2006 5:59 am
by ajith
Is there a way in which I can populate the Fixed width file with Varchar and Integer fields padding them with space beyond their length?

It seems stupid, but if there is a way, I would be able to save a lot of stages.

Thanks in advance,
Ajith

Posted: Thu Nov 30, 2006 6:37 am
by keshav0307
yes. define the target file format correctly for fixed width.
possibly you can define all the field of type char.

Fixed Width File

Posted: Thu Nov 30, 2006 6:42 am
by talsimad
you can use a transformer to pad your varchar or integer columns with spaces:
you have to use the function PadString it's very simple to use, for exemple if your have a varchar(10) column C and you got "abc" in this column if you want to pad C with 7 spaces:
PadString(C,' ',10-Len(C)) --> rignt padding
or
PadString('',' ',10-Len(C)) --> left padding.

good luck :wink:

Posted: Thu Nov 30, 2006 6:49 am
by DSguru2B
Simplest way would be to define the target file as fixed width and specify the fields as char. That should take care of it.

Posted: Thu Nov 30, 2006 7:07 am
by ajith
Thanks for all the replies.

I am currently defining every column as char and converting each and every column to char, I was just wondering, if i can avoid these conversions that would be very helpful.

There is no way to write a Varchar directly without using a modify or transformer to a fixed width file?. I was just trying to minimize the use of those stages (modify and transformer).

Thanks in advance,
Ajith

Posted: Thu Nov 30, 2006 1:58 pm
by ray.wurlod
Make it Char and it will be padded automatically with the character defined in APT_STRING_PADCHAR.