Wednesday, 13 March 2013

Flat File Schema in Biztalk



Flat File Schema:  A flat file schema defines the structure of a class of instance messages that use a flat file format, either delimited or positional or some combination thereof.

Several Legacy system are based on flat files .So conversion of flat files to xml is required in integration projects.

A Flat Files is of several Types:
  • ·         Delimiter,
  • ·         Positional and
  • ·         Combination of both.

Biztalk provides Flat File Schema Wizard for creating flat files Schemas.

In this article we will develop flat file schema for complex file using flat file schema wizard

Example:
INVOICE12345
DestinationPartnerURI:http://www.contoso.com?ID=1E1B9646-48CF-41dd-A0C0-1014B1CE5064
BILLTO,US,John Connor,123 Cedar Street,Mill Valley,CA,90952
101-TT         Plastic flowers   10   4.99      Fragile handle with care
202-RR         Fertilizer        1    10.99     Lawn fertilizer        
453-XS         Weed killer       1    5.99      Lawn weed killer       

In this flatfile there are 4 Type of record

Step 1: Create New Biztalk Project
Step 2: Add New Item, Select Flat File Schema Wizard



















Step 3: Select Instance File.



















Step 4 : Every line in the flat file is delimited by CRLF , hence  Select option  By Delimiter Symbol.


















Step 5: Select Child delimiter as {cr}{lf}.

Step 6: Define Child elements .

·         The Elements type in case of Destination partner and bill to is record because it has more delimiter based fields.
·         The Elements type in case of Item is repeating record because it is repeating several times.
















Step 7: define field properties for each type of record.

Step 8: Destination partner have field with Delimiter (: ) , so select delimiter.















Step 9: BillTo record is based on delimiter (,) , hence select by Delimiter symbol option.














Step 10: now record item is position based, so define the position of each element.











After generating the Schema, right click on schema and validate the instance


Wednesday, 6 March 2013

convert flat structure into hierarchal using Table Looping Functoid



This tutorial describes how to convert flat structure schema to hierarchal schema using Table Looping functoid.

Input Schema: FlatStructure.xsd




















Target Schema:
 
















Map for conversion:

































Input Instance for Test:


<ns0:FlatStructure xmlns:ns0="http://Company.Demo.TableFunctoid.FlatStructure">
  <Name>Name</Name>
  <ResidentialAddressLine1>ResidentialAddressLine1</ResidentialAddressLine1>
  <ResidentialAddressLine2>ResidentialAddressLine2</ResidentialAddressLine2>
  <ResidentialAddressCity>ResidentialAddressCity</ResidentialAddressCity>
  <ResidentialAddressState>ResidentialAddressState</ResidentialAddressState>
  <OfficeAddressLine1>OfficeAddressLine1</OfficeAddressLine1>
  <OfficeAddressLine2>OfficeAddressLine2</OfficeAddressLine2>
  <OfficeAddressCity>OfficeAddressCity</OfficeAddressCity>
  <OfficeAddressState>OfficeAddressState</OfficeAddressState>
  <GaragedAddressLine1>GaragedAddressLine1</GaragedAddressLine1>
  <GaragedAddressLine2>GaragedAddressLine2</GaragedAddressLine2>
  <GaragedAddressCity>GaragedAddressCity</GaragedAddressCity>
  <GaragedAddressState>GaragedAddressState</GaragedAddressState>
</ns0:FlatStructure>



Output Instance :

<ns0:HierarchyStructure xmlns:ns0="http://Company.Demo.TableFunctoid.HierarchyStructure">
  <Addresses>
    <Address>
      <AddressType>Residential</AddressType>
      <Line1>ResidentialAddressLine1</Line1>
      <Line2>ResidentialAddressLine2</Line2>
      <State>ResidentialAddressState</State>
      <City>ResidentialAddressCity</City>
    </Address>
    <Address>
      <AddressType>Office</AddressType>
      <Line1>OfficeAddressLine1</Line1>
      <Line2>OfficeAddressLine2</Line2>
      <State>OfficeAddressState</State>
      <City>OfficeAddressCity</City>
    </Address>
    <Address>
      <AddressType>Garaged</AddressType>
      <Line1>GaragedAddressLine1</Line1>
      <Line2>GaragedAddressLine2</Line2>
      <State>GaragedAddressState</State>
      <City>GaragedAddressCity</City>
    </Address>
  </Addresses>
</ns0:HierarchyStructure>



Use of Gated Checkbox :

When you select this check box, you are specifying that the value of the data specified for column 1 controls whether any processing is performed for that row. When this is output from a logical functoid, if the value specified in column 1 evaluates to False, the associated row of the grid is skipped (meaning that the associated Table Extractor functoids are not invoked for that row).

Code Available Here