A flat file in the Designer is defined via the following structure:

  1. A flat file definition
    This is a class having the stereotype FlatFile. It represents the file itself. The properties of this class represent the data records.
  2. One or more flat file record definitions
    These are classes having the stereotype FlatFileRecord. They represent the data records of the flat file and are used as a type for the properties of the FlatFile class.
  3. One or more flat file record properties
    These are properties of the FlatFileRecord having the stereotype FlatFileAttribute. They represent the data fields of the flat file record.

Each flat file stereotype comes with a list of attributes to define certain functionality like length, format, order and more.

The following class diagram shows the flat file structure of the related example:

Defining the Flat File

Define a flat file by creating a root class with stereotype FlatFile. The properties of this class must be complex and specified as to be flat file records. A flat file can have multiple flat file record definitions representing different record types. In the example above these are Header and Product.

Assign a meaningful name because the output object flow of the Flat File adapter action uses this class as a type.

A flat file can have the following stereotype attributes specified:

Defining the Flat File Record

Define a flat file record by applying the stereotype FlatFileRecord to a class. Such classes can be used as types for properties of flat file definitions (ProductList in the example above).
Flat file records have properties that specify the structure and layout of the record. You can specify e.g. the sorting order of the properties within the record, the format of number properties, the record layout (separated, fixed, pattern) and more.

A flat file record can have the following stereotype attributes specified:

Defining Flat File Record Properties

Properties of a flat file record specify the structure and layout of the record. All properties need to have stereotype FlatFileAttribute applied. Depending on the layout type of the flat file (separated, fixed or pattern), you can specify different attributes.

Attribute Settings for Separated Flat File Record Layout

Whether a flat file has a separated layout is specified on the flat file record class in attribute attributeLayout. For records with a separated layout, you must specify a separator in attribute attributeSeparator. The default separator is ',' (comma).
The order of properties is defined on the property by either the order attribute or by specifying an offset within the record.

A flat file record property that is part of a can have the following stereotype attributes specified:

Attribute Settings for Fixed Flat File Record Layout

Whether a flat file has a fixed layout is specified on the flat file record class in attribute attributeLayout. With fixed layouts, each record property has a fixed length given by the externalLength attribute. Optionally, you can specify a padding to fill the attribute from the left or right side with a given character.
The order of properties is defined on the property by either the order attribute or by specifying an offset within the record.

A flat file record property can have the following stereotype attributes specified:

The Flat File Example

The flat file example service defines a flat file with a fixed layout. The following table explains the flat file definitions for this example:

ElementStereotypeStereotype AttributeDescription
Flat FileProductListFlatFile-
Defines the flat file structure ProductList.
Flat File RecordHeader



FlatFileRecordattributeLayoutfixedSpecifies the header record as to be structured by fixed lengths.
composeMacroResetCounter(AUTO0)Reset the automatic counter AUTO0 when this record is composed.
evalutationOrder1Evaluate this record first, before evaluating the product records.
lineNumber1This header record is the first record in the file.
Product

FlatFileRecordattributeLayoutfixedSpecifies the product record as to be structured by fixed lengths.
evaluationOrder2Evaluate this record second, after evaluating the header record.
Flat File Property


line


FlatFileAttributecomposeMacroGetCounter(AUTO0)This property is set from the automatic counter AUTO0.
externalLength5This property has a length of 5 characters in the record.
order10

This property is the first property in the record (as all other properties have a higher order).

Use two-digit numbers for order. This way, the record layout can easily be updated, and you can easily fit an additional property somewhere in between.

number

FlatFileAttributeexternalLength5This property has a length of 5 characters in the record.
order20This property is the second property in the record.
name

FlatFileAttributeexternalLength20This property has a length of 20 characters in the record.
order30This property is the third property in the record.
category

FlatFileAttributeexternalLength20This property has a length of 20 characters in the record.
order40This property is the fourth property in the record.
type
FlatFileAttributeexternalLength10This property has a length of 10 characters in the record.


order50This property is the fourth property in the record.
price



FlatFileAttributeexternalLength10This property has a length of 10 characters in the record.
order60This property is the sixth property in the record.
formatFM0000000.00The price should be formatted like specified, e.g. 0000065.50.
paddingLeft("0")The price should be filled with zeros from the left side, e.g. 0000065.50.
serviceInterval


FlatFileAttributeexternalLength5This property has a length of 5 characters in the record.
order70This property is the seventh property in the record.
paddingLeft(" ")The service interval should be filled with blanks from the left side, e.g. "   52".