The FLATFILE handler converts an outbound integration message into a flat file and writes it to a directory that has a configurable location. Flat files contain ASCII data in the form of rows and columns. Each line of text constitutes one row, and a separator character separates each column in the row. The FLATFILE handler encodes outbound flat files in the standard UTF-8 format.
The FLATFILE handler can be used only with publish channels, not invocation channels. The object structure associated with the publish channel must be configured to support flat files. You must resolve all alias conflicts for the object structure and format the XML message according to the object structure schema before writing the message to a flat file.
File names require the following format.
externalsystemname_publishchannelname_uniqueidentifier.dat
The following example file name indicates that the file goes to the external system EXTSYS1 and was published through the MXASSETInterface publish channel:
EXTSYS1_MXASSETInterface_10971102668641498.dat
The first two lines of the file contain header information. The first line has the following format:
externalsystemname <separator> publish channel name <separator> [action] <separator> langcode
The second line of the file contains the names of the columns, separated by the separator character. The column names are the same as the names in the corresponding interface table.
If the data in the flat file contains the flat file delimiter character, the data adds the text qualifier, which is " (quotation marks). If the data contains quotation marks, the handler escapes the quotation marks. You cannot use quotation marks as the delimiter character.
The following example data uses a comma (,) as a delimiter. The INVOICEDESC value, (Rotating Custom Item, No 71), contains a comma. When the flat file is written, the INVOICEDESC value is enclosed in quotation marks.
EXTSYS1,MXINVOICEInterface,Add
INVOICENUM,INVOICEDESC,PONUM,VENDOR,CONTACT,PAYMENTTERMS
1071,"Rotating Custom Item, No 71",1000,A0001,,
The following example data uses a comma (,) as a delimiter. The INVOICEDESC value (Rotating "Custom" Item No 71) contains double quotation marks. When the flat file is written, double quotation marks in INVOICEDESC data ends with quotation marks, and the entire string is wrapped in quotation marks.
EXTSYS1,MXINVOICEInterface,Add
INVOICENUM,INVOICEDESC,PONUM,VENDOR,CONTACT,PAYMENTTERMS
1071,"Rotating ""Custom"" Item No 71",1000,A0001,,
The following example data uses a comma (,) as a delimiter. The INVOICEDESC data (Rotating "Custom" Item, No. 71) contains the delimiter character and double quotation marks. When the flat file is written, the INVOICEDESC value appears in the code.
EXTSYS1,MXINVOICEInterface,Add
INVOICENUM,INVOICEDESC,PONUM,VENDOR,CONTACT,PAYMENTTERMS
1071,"Rotating ""Custom"" Item, No. 71",1000,A0001,,
The FLATFILEDIR property is a required property that specifies the location of the flat file on a file server that is made available to you by your system provider.
The FLATFILESEP property is a required property that specifies the character that separates the columns in each row.