Focal Point
[SOLVED] How to create a fixed width text file using DM

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/4547097926

March 27, 2013, 07:39 PM
Phil DeBusk
[SOLVED] How to create a fixed width text file using DM
We are having difficulty creating a fixed width file using Data Migrator. First it seems we "must" choose "Delimited Flat File" for the output otherwise other file types return control chars or other junk. This might not be an issue even though we have no delimiter (fixed width). Next our biggest issue is when we encounter empty columns on right hand side of the file. For instance if the right most column begins at position 100 and is 10 spaces wide we would expect the file to have a length of 110 spaces. However if the data is null on the right most column it collapses and we receive an output file which is only 100 chars. This won't work for us. We've tried various functions to pad the output in the event of null data but nothing seems to work. The "sample data" even shows the spacing on a null column which gives you a false sense that it will produce the correct file width. Anyone experience this and overcome it? Thanks. My data migration simply pulls from a SQL database where some columns happen to be null top to bottom. Still the correct spacing is required by the receiving system which expects a fixed width flat file of exactly X width.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.6
Windows, All Outputs
March 28, 2013, 02:42 PM
Twanette
Hi,
As a matter of interest - which platform / OS are you running on?

I think I have managed to overcome the issue when the last field has spaces, but I can't remember how. However, a workaround that I occasionally use is to add a field at the end of the row which is forced to have a value e.g. the system date, or a dummy field with a value of "X".


WebFOCUS 8.2.01M/8.2.02M mostly Windows Server
March 28, 2013, 03:19 PM
Phil DeBusk
Sure: We are running ver 7704 update(758) on Windows 2008 R2 (64bit). That is a good idea about placing a char at the far right say 1 char over the fixed width size. I would prefer not to have to resort to this but I might give it a try. The flat file is processed by our ERP system and I'm not sure if it will choke on the extra char on the end. Question for you. Did you use a delimited file choice or were you able to use another option to arrive at a fixed width file? Thanks for your help.


WebFOCUS 7.6
Windows, All Outputs
March 29, 2013, 04:55 AM
Twanette
Hi Phil,
From what I can remember I selected "Formatted File" as my Target adapter, and then I selected ALPHA as the Format. This should generate a "HOLD FORMAT ALPHA" statement - and I seem to think that automatically kept trailing spaces.

Just BTW - one of the approaches which may give you better control when loading a sequential table with a specific layout is to first create a synonym for the format that you want, and then to use that synonym as your target.


WebFOCUS 8.2.01M/8.2.02M mostly Windows Server
March 29, 2013, 05:23 AM
Alan B
With Delimited Flat File I would not expect this to be a true fixed width file when the last column is null or blank.

First I would transform the source into new fields, without the Missing attribute. Then I would output as a Formatted File, Format ALPHA.

This should produce a clean fixed width file.


Alan.
WF 7.705/8.007
March 29, 2013, 10:49 AM
Phil DeBusk
Thanks Twanette and Alan B. Your suggestions were spot on. While experimenting we actually used the flat file option then set all columns to alpha fixed and padded to their necessary widths. This produced a clean file with correct spacing however I will look at changing this to "formatted - alpha" as that sounds like the best approach. Thanks again.


WebFOCUS 7.6
Windows, All Outputs