Today, yet another post on Microsoft.public.biztalk.nonxml caught my attention. In this post, the out of the box flat file disassembler is used to parse a file looking like:
| 20040511| AAAA | 138| 1012101
| 20040511| BBBBBBB | 11111117| 1101701
Observe the space after the vertical bar (|). This is the perfect example to illustrate how the flat file disassembler could be used.
1: Building the schema for the flat file disassembler:It is useful to first determine how the output XML will look like. We will choose the following output:
This flat file has no header or trailer so only a body schema will be involved here. The next step is to identify the format of the record. Basically, this is a list of records delimited by CR LF. Observe that the field's data appears before the delimiter so the Child Order should be set to "Postfix" (see here).
Records are delimited by the string (| ) and not positional. Note that I included the space after the vertical bar to avoid getting an irrelevant space in the output. The child order should be "Prefix" (sequence is delimiter then data).
Every record has four fields. The first one and second one are left aligned, the third one is right aligned and the last one is left aligned. This allows to trim the spaces effectively. We have now all we need to build the schema for the flat file disassembler. Create a new schema in a BizTalk project and make sure you enable the Flat File Extension. Here is a representation of the schema and its properties, once designed:
Records Child Delimiter = 0x0D 0x0A, Type = Hexadecimal, Child Order = Postfix, Structure = Delimited
Record Child Delimiter = | , Type = Character, Child Order = Prefix, Structure = Delimited
Date Justification = Right
String Justification = Left
Num1 Justification = Right
Num2 Justification = Right
2: Running the pipeline without deploying:
To avoid rebuilding/deploying the schema all the time for the purpose of testing, BizTalk 2004 offers an utility called FFDAsm.exe. It is located in %BTSROOT%\SDK\Utilities\Pipelines. Here is one way to call it:
FFDAsm schemaFlatFile.xsd -bs inputmessage.txt -c