Click here to Skip to main content
6,595,444 members and growing! (20,935 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft BizTalk Server » General     Beginner

Creating Flat File schemas using the BizTalk Server 2006 Flat File Schema Wizard

By Naveen Karamchetti

An article explaining how to generate a flat file schema in BizTalk Server 2006 using the Flat file schema wizard
Windows, .NET, Visual Studio, Dev
Posted:6 Apr 2006
Updated:20 Apr 2006
Views:41,542
Bookmarked:25 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
15 votes for this article.
Popularity: 4.10 Rating: 3.49 out of 5
3 votes, 20.0%
1
1 vote, 6.7%
2
2 votes, 13.3%
3
2 votes, 13.3%
4
7 votes, 46.7%
5

Introduction

An accurate Flat File schema is very important in every integration project. Several legacy projects have been operational on Flat file format, converting these flat files into XML is vital to the success of any integration project. The new Flat file schema Wizard in BizTalk 2006 is just the right tool for the job. This article shall attempt to explain the various features and things to look out for while creating a flat file schema using the Wizard.

Background

In case you are a newbie to this flat flat structures, please read the following articles on Flat file schemas...

Flat file structure - Quick Intro...

A flat file unlike a XML file, does not have any visible inherent structure. A flat file's structure is evident from its usage and also requires some domain knowledge to understand its representation. A flat file structure is several types

  1. Delimited flat file.
  2. Positional flat file.
  3. A flat file with combination of Delimited and Positional records.
In this article we shall generate a schema for a medium-complex flat file using the BizTalk 2006 Flat File Wizard.

Example - A complex positional flat file

810HDR    Invoice   1972-05-12John Doe            
810DTL    01-2304040200       $2.34     
810DTL    02-4030400400       $1.34     
810TOT    600       $1004     
810END    Steven    
  1. In the example above, there are 5 lines, each line represents a "record" of information.
  2. A Positional flat file is one whose fields are placed in positions (columns), whose field lengths are fixed in size. The "ID" field is of fixed size of 10 characters, the "Description" field is of fixed size of 10 characters, the "DOB" is of fixed size of 10 characters and the "Full Name" is of fixed size of 20 characters.
  3. Notice that every record is of different type/structure.

The Data dictionary for the flat file

810HDR (Total = 50 characters)
     - Header ID     - 10 characters    
    - Description     - 10 Characters
    - Date of Birth - 10 Characters
    - Full Name     - 20 Characters

810DTL (Total = 40 characters)
    - Detail ID    - 10 characters
    - Part No     - 10 characters
    - Quantity     - 10 characters
    - Price    per unit- 10 characters

810TOT (Total = 30 characters)
    - Total ID     - 10 characters
    - TotalQuantity    - 10 characters
    - TotalPrice     - 10 characters

810END (Total = 20 characters)
    - END ID     - 10 characters
    - ClerkName    - 10 characters

Using the BizTalk 2006 - Flat File Schema Wizard

Create a new BizTalk Server Project in Visual Studio 2005.

Step 1 : In the Visual Studio 2005 menu, select the File -> New -> Project -> and select "Empty BizTalk Server Project" and type the name "FFSchemaDemo"

Step 2 : In the Solution Explorer, right click on the project name "FFSchemaDemo" and select Add -> New Item. In the "Add New Item" dialog box, select the "Flat File Schema Wizard" and type the Name as "FFSchema_Wiz.xsd".

AddNewItem.PNG

Step 3 : In the screen that appears specify the flat file (*.txt) location. This will help the Wizard load the file for parsing. Specify the ROOT (Record name) element name for the schema. Observe the Red boxes in the screen shot.

Wiz_1.PNG

Step 4 : Notice the entire file being loaded into the Wizard with the New line separators (CRLF) being marked visually.

Wiz_2.PNG

Step 5 : Every line in the flat file is delimited by CRLF, whereas every field within a line is positional. Hence select "By delimiter symbol".

Wiz_3.PNG

Step 6 : Since every line is separated by CRLF characters, specify this option in the Child Delimiter drop down text box.

Wiz_4.PNG

Step 7 : Defining Child elements is the most critical part of the Wizard steps. In the example that we considered, there is one Header line, two detail lines, one total line and one end line. The Element name specifies the top level elements that appear in the final schema. The Element type, in the case of a HDR is "Record", since it contains several other positional fields. The Element type for "DTL" is a "Repeating record" since the similar kind of record is repeated on the third line in the file. The Element type for the third line is set to "Ignore", since "DTL" is being repeated on the third line. Note that the "Ignore" option is designed, for this purpose alone. For the subsequent lines, the Element type is set to "Record".

Wiz_5.PNG

Step 8 : The top level elements are being depicted.

Wiz_6.PNG

Step 9 : The first line is selected, notice that the line separators are not being selected by default.

Wiz_7.PNG

Step 10 : We need to specify that the fields in the selected record are positional.

Wiz_8.PNG

Step 11 : The sizes for each field in a positional record and the Tag Identifier, used to identify each line are being specified. The arrows which fix the column sizes can be toggled by a mouse click. Important : Note that, if there are five fields then you would need to fix only four arrows.

Wiz_9.PNG

Step 12 : The Field names and types need to be specified for each field.

Wiz_10.PNG

Last Step : The similar steps need to be followed to complete the field definitions for all the lines in the file.

Wiz_10.PNG

Schema Validation

Once the schema has been generated, validate the schema by right clicking on the file and selecting "Validate Schema" menu option.

Takeaways

The Flat file schema wizard simplifies schema creation. NOTE that the schema wizard expects the complete instance of the flat file to be present for the schema generation. If there are any optional records, they would need to be mapped manually once the schema is created.

About the Downloadable code

  • Unzip the zip file in the C:\ drive.
  • The flat file sample is placed in the FlatFilesInput directory in the zip file.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Naveen Karamchetti


Member
Naveen Karamchetti has done his Masters (M.S.) in Software Engineering from B.I.T.S, Pilani and is based out of Fremont, CA.
The author has more than 8.5 yrs of experience in the IT industry, has started his career
starting from the good old days of using a Unix, Tcl/tk. The author has been associated with
several companies based out of Silicon Valley, California.

The author has won several programming awards within the organizations worked and is well-recognized. The author has also worked for Microsoft based at Redmond.

Hobbies include training, mentoring and research. Spends his free time travelling in the BART (Bay Area Rapid Transit) in Fremont, CA.
Occupation: Software Developer (Senior)
Location: United States United States

Other popular Microsoft BizTalk Server articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
Generalhow To Produce Flat File From Xml PinmemberAunalisiraj19:50 9 Mar '08  
Questionflat file parser.... PinmemberDeven Bhatt0:02 22 Oct '07  
GeneralExcellent article PinmemberSantosh Benjamin10:30 16 May '07  
GeneralZzzzzzzzzzz PinmemberHeywood11:49 21 Apr '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Apr 2006
Editor:
Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project