Fixed Length
A fixed-length format file or a flat file is one that contains data encapsulated as fields that are of fixed length and each row forms a record. The length of the field and row is determined by the implementing party and is typically a custom format.
Fixed-Length Structure
The high-level structure of a fixed length file consists of :
FixedLengthRecord — Each line in the file forms one record which must be of a fixed length.
FixedLengthField - Each record contains fields that are of fixed length each. Fields are not delimited by any character.
Fixed-Length Row
Each row in a fixed-length format file is of a fixed length structure. For example, a row can be of 50 characters length with multiple fields within each of a specific fixed length.
20160425230000CC DF0090016100Q 000000
Fixed-Length Format Metadata
Each fixed length format file will conform to a specific set of rules that will indicate the position and occurrence of the fields within each row of the file. This set of rules are defined inside an XML metadata file.
Example of the XML metadata rule file –
The metadata XML files will reside in “<base module pkg>.integ.fixlen.rules”. These rule files will be deployed along with other artifacts.
The metadata rule file will have the FixLenDef element followed by a number of FixLenFieldDef elements. The field elements have the following attributes :
Name Name of the field. This will be used for fetching the field value from the processor.
starting position : This is the starting position/offset for the field on the file. This will start from 1 and can go up to the length of the row. For example, if the startingPosition is 68, this means the field value will start from the 68th position in the file.
Length: This is the length of the field. For example, if the startingPosition is 68 and length is 5, then it means the field value begins at 68th position up to 5 chars (up to position 72)
Type: This is the field type – it could be numeric, signed numeric or alphanumeric. Signed numeric is a numerical field with sign.
MandatoryWhenSent – This indicates if the field value is mandatory in outbound file.
O Optional
M Mandatory
C Conditional - Conditional fields will be assumed as optional fields by the FixedLengthFormatFile parser. The implementing processor may choose to throw error if the field is conditional on any other field.
MandatoryWhenReceived - This indicates if the field value is mandatory in inbound file. Possible value for mandatory field :
L Padding if present, will be on the left side of field value
R Padding if present, will be on the right side of field value
If a numeric/signed numeric is right padded with 0, then it won’t be considered padding unless it comes after a decimal point.
PadDirection – Indicates the direction of padding.
Padding – Indicates the padding character.
0 Padded with Zeroes (Usually for numeric or signed-numeric fields) 0 padding on the right for non-decimal numeric fields will not be considered as padding because the parser won’t be able to determine if it’s a part of the value or padding
B Padded with blank spaces