Wednesday, 24 April 2013

Biztalk Maps: Samples for Biztalk Mapping Types( One to One and ...

Biztalk Maps: Samples for Biztalk Mapping Types( One to One and ...: This blog is helpful for BizTalk maps beginners. I would like to start my blog with types of mapping scenarios. For every mapping we f...

Wednesday, 27 March 2013

Samples for Biztalk Mapping Types(Many to One and Many to Many)

Many-To-One Mapping:
In this Mapping, multiple elements are mapped to single element. 

In the above Example, Many address elements are mapped to single address element. An Employee can have multiple addresses like Permanent, Present, etc. In the Source Schema, Address elements concatenated with 1 (EmpStreet1, EmpCity1, EmpState1, EmpPostalCode1 and EmpCountry1) belongs to Permanent Address and Address elements concatenated with 2 (EmpStreet2, EmpCity2, EmpState2, EmpPostalCode2 and EmpCountry2) belongs to Present Address.  All these Permanent and Present Address elements are mapped to the elements under Address node in the destination schema using Table Looping and Table Extractor Functoids. For Example, both Empstreet1 and EmpStreet2 of Source schema are mapped to the element Street under Address node of destination schema.

Here String Concatenate Functoid is used to hard code the values Permanent and Present.

Table Looping Functoid is as shown below:
In the above image, the first parameter is the Scoping link (EmployeeSource link), second parameter is the number of columns required in the data grid (in our example, we need to map the elements Type, Street, City, State, Country, Postal code. So number of columns required = 6) and remaining are the Source inputs used for mapping.

Note:  Label the links after mapping to Table Looping Functoid. So that u can easily configure the columns in the Table Looping Data grid.

After mapping our inputs to Table Looping Functoid, We have to configure the Table Looping Data Grid by selecting the input parameters as shown below:

To open Data Grid -> Right click on Table Looping Functoid and select Configure Table Looping Grid

In the above image, Column 1 is configured with Permanent and Present in two rows that indicate Address types;
Column 2 is configured with EmpStreet1 and EmpStreet2,
Column 3 is configured with EmpCity1 and EmpCity2
Column 4 is configured with EmpState1 and EmpState2
Column 5 is configured with EmpPostalcode1 and EmpPostalcode2
Column 6 is configured with EmpCountry1 and EmpCountry2

First Table Extractor Functoid is as shown below:
This Functoid will extract the data from the Table Looping Column.
In the above image, First parameter is the Table Looping link and the second parameter is the table looping Column number.
So for the remaining 5 Table Extractor Functoids, need to give the second parameter as 2,3,4,5 and 6.

Many-To-Many Mapping:

Here an Employee can have multiple Phone numbers like Work phone, Personal phone, Alternative phone, etc.
In our example, Phone Number is mapping to multiple elements based on the Phone Number Type.
For Phone Number Type value checking and mapping, i have used Logical Equal Functoids and Value Mapping Functoids.
To read multiple Phone Numbers Types in input Source Message, i have used Looping Functoid.
Here the Looping Functoid is mapped to three Phone Numbers (Workphone, Personal Phone and Alternate Phone Numbers) in destination schema to check each type of Phone Number in input Source Message for each Phone Number in destination schema.

The three Logical Equal Functoids for three Phone Number Types are as shown below:

In  Logical Equal Functoid, if first parameter value equal to second value then it returns true otherwise false.

The three Value Mapping Functoids to check three Phone Number Types for mapping three different Phone Numbers are as shown below:


In Value Mapping Functoid, if first Parameter value is true the second parameter value is going to map otherwise not.

 The Input and Output messages for the above mappings are shown below:
Input Source Message:
<ns0:EmployeeSource xmlns:ns0="http://SimpleMappingProject.EmpSource">
  <EmpStreet1>Sixth street</EmpStreet1>
  <EmpStreet2>Eighth Street</EmpStreet2>

Output Message:
<ns0:EmployeeDestination xmlns:ns0="http://SimpleMappingProject.EmpDest">
  <Address Type="Permanent">
    <Street>Sixth street</Street>
  <Address Type="Present">
    <Street>Eighth Street</Street>