Page 1 of 1

Fixed Width Length

Posted: Thu Aug 28, 2014 1:04 pm
by sam334
All,
Have a question on fixed width length file. The file has 30 columns. The last column has 12 bytes. So, we put Char(12). In the file there some records which have 11 bytes. So, if we checked suppress row truncation warning, its rejecting some records. If unchecked its aborting on the row where bytes become 11 from 12 bytes (too many records in column).

Any thought how we can achieve this where sequential file will read a fixed width file where in column the lengths are not fixed.

Re: Fixed Width Length

Posted: Thu Aug 28, 2014 2:24 pm
by chulett
sam334 wrote:Any thought how we can achieve this where sequential file will read a fixed width file where in column the lengths are not fixed.
No such thing. If the lengths are not fixed then it needs to be a delimited file. Fixed is fixed, not mostly fixed. :wink:

Question though, is this only an issue with the last field? Does the file have record delimiters in it?

Posted: Thu Aug 28, 2014 2:40 pm
by sam334
Craig. Thanks. That's what i thought. There is no delimiter. It has always been a fixed width length file. There was a change in source system. After that we are getting the file like that.

The problem is in the last column where the change occurred.

Column looks like,

SS01012005PP which is char(12)
S01012005P which is char (10)

Before it was CHAR(15). So, there was fixed length with spaces at end of each record. Now the spaces are removed.

The file was initially a TRAIL process now changed to NOTRAIL process for which spaces at end of last column truncated.

Is there any way we can read the trailing blanks ?

Thanks a lot.

Posted: Thu Aug 28, 2014 3:43 pm
by chulett
Without it being "fixed width delimited" (i.e. fixed width fields but with a record delimiter) then they must ensure that those trailing spaces are preserved as the file is read byte by byte based on the sizes you define. Have the source system correct the file.

You're certain about the record delimiter? A true fixed-width file will look like 'one long record' and will thus give you a wc -l count of 1. If there are standard record delimiters then wc -l will return a 'true' count of the records in the file.

Posted: Wed Sep 03, 2014 8:52 am
by sam334
Ok. Thanks Craig. We changed the source file.

Thanks again