Click here to Skip to main content
Click here to Skip to main content

Flattening Out the Complexity in Flat File Schemas in BizTalk 2004 - Part 3

, 6 Apr 2006
Rate this:
Please Sign up or sign in to vote.
An article explaining how to write various flat file schemas in BizTalk Server 2004

Introduction

In this article, I shall attempt to explain flat file schema structures with optional records. In other words, I will explain how to create a flat file schema which has a option record, which can appear 0 or more times.

Background

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

Flat File Structure - Quick Intro

A flat file, unlike an 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 of several types:

  1. Delimited flat file
  2. Positional flat file
  3. A flat file with combination of Delimited and Positional records

Consider an example flat file shown below in which the lines starting with "810DTL" and "810TOT" are optional.

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    

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) - OPTIONAL  (occurs 0 or more times)
    - Detail ID    - 10 characters
    - Part No     - 10 characters
    - Quantity     - 10 characters
    - Price    per unit- 10 characters

810TOT (Total = 30 characters) - OPTIONAL (occurs 0 or 1 time)
    - Total ID     - 10 characters
    - TotalQuantity    - 10 characters
    - TotalPrice     - 10 characters

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

Notice that the "810DTL" and "810TOT" records are OPTIONAL.

New BizTalk Server Project in Visual Studio 2005

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" and type the Name as "FFSchema_Group.xsd". Create the structure as shown in the screen shot.

Step 3: Note the use of "Sequence" tag to specify optional records. A "Sequence" element can be used to specify whether an element is optional or not.

FFSchema_Group.PNG

Step 4: Observe the properties of the DTL element which specify the "Min Occurs" and the "Max Occurs" properties.

FFSchema_Pro.PNG

"Choice" XSD Element

The same functionality can also be obtained by using a "Choice" element. Please observe the use of the Choice element.

FFschema_Choice.PNG

Observe the properties being set on the Choice element. The value of Max Occurs is "*" which means that the number of nodes coming out from the Choice element is unlimited.

FFSchema_ChoiceProperties.PNG

Schema Instance Validation

Once the schema has been created, validate the instance of the schema by right clicking on the file and selecting "Validate Instance" menu option. Verify the output file generated.

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.

History

  • 6th April, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Naveen Karamchetti
Architect AT&T Wi-Fi Services
United States United States
Naveen has done his Masters (M.S.) in Computer science, has started his career programming the mainframes and now has more than a decade of programming, development and design experience. Naveen has a sharp eye and keen observation skills. Naveen has worked for several companies and strived hard to build large scale business applications and bringing better solutions to the table.
Quite recently Naveen has built a fairly complex integration platform for a large bank. His hobbies include training, mentoring and research. Naveen spends his free time visiting National Parks nationwide.
 
Naveen has developed the BizTalk Control Center (BCC)
http://biztalkcontrolcenter.codeplex.com

Comments and Discussions

 
Generalconverting sql data to flat file PinmemberThunderBiz27-Apr-07 14:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140718.1 | Last Updated 6 Apr 2006
Article Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid