Wednesday 27 March 2013

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



This blog is helpful for BizTalk maps beginners. I would like to start my blog with types of mapping scenarios. For every mapping we first think about the type of mapping. Mappings are categorized into two:
1.       Simple Mapping
2.       Complex Mapping
Simple Mapping:
                For beginners, it is better to start with Simple Mapping. The Source and Destination elements have One-to-One relationship. We can either directly map the elements or apply many types of transformations and translations using multiple Functoids depending on the requirement.
Complex Mapping:
                Complex Mapping involves the elements with One-to-Many, Many-to-One and Many-to-Many relationships. Before starting the complex mapping, it is better to see the properties of source and destination elements that you would like to map. Why because, most of the times complex mapping fails due to property values.

I would like to show samples separately for different mapping scenarios by using Employee details.

Source Schema:


Destination Schema:


Mapping Scenarios
One-To-One Mapping:
In this mapping, Single element is mapped directly to Single element.
 

In the above example, we can observe direct mapping of EmpNo and Names from source to destination. 

Sample Input Message for the mapping fields:

<EmpNo>1023</EmpNo>
<EmpFirstName>John</EmpFirstName>
<EmpMiddleName>k</EmpMiddleName>
<EmpLastName>Mackson</EmpLastName>

Output Message:

<EmpNo>1023</EmpNo>
  <Name>
    <FirstName>John</FirstName>
    <MiddleName>k</MiddleName>
    <LastName>Mackson</LastName>
  </Name>
 
 
 

One-To-Many Mapping:
In this mapping, one element can mapped to multiple elements. 

In the above example, DateofJoining value is divided and mapped to multiple elements. Here I used Scripting Functoid to separate the year, month and day from date value.

The three Scripting codes are as shown below:
 
 
In second and third scripting Functoids, hyphens are added to the month and day values to valid the xsd:gmonth and xsd:gday data types for the elements Month and Day in destination schema.



Sample Input Message for the mapping field:
<DateofJoining>1982-02-01</DateofJoining>

Output Message:
<DOJ>
    <Year>1982</Year>
    <Month>--05</Month>
    <Day>---01</Day>
</DOJ>

Samples for Many to One and Many to Many Mappings will be in next post.

No comments:

Post a Comment