Create a map that utilizes the BizTalk Server Looping functoid, by taking the following steps:
1. Click the Toolbox, and then click the Advanced Functoids tab. On the map surface, between the source and destination schemas, drag and drop a Looping functoid. This functoid accepts 1 to 100 repeating source records (or data elements) as its input parameters. The return value is a reference to a single
repeating record or data element in the destination schema.
2. Connect the left side of the Looping functoid to the multiple repeating source data elements that need to be consolidated.
3. Connect the right side of the Looping functoid to the repeating destination data element that contains the standardized data structure.
Note: The records of source and destination schema's should be set as max occurs "unbounded". You will get error if you set up as Group max occurs instead of max occurs.
Looping Functoid:
Use the Looping functoid to combine multiple repeating structures in an input instance message into a single repeating structure in the output instance message.
Input:
Parameters 1 – 100: A link from at least one repeating node in the source schema, and optionally, links from other repeating nodes in the source schema.
Output:
Output 1: A link to a single repeating node in the destination schema.
The input and output links for the Looping functoid define the repeating structures in an input instance message that are combined into a single repeating structure in an output instance message. However, additional links are required from nodes within the repeating nodes in the source schema to the appropriate nodes within the repeating node in the destination schema. Without these additional links, the repeating structures are combined, but without any of the data that they contain.
For example, if there are two input links and their corresponding structures repeat 5 and 10 times, respectively, in a particular input instance message, the corresponding structure in the output instance message repeats 15 times.
The Looping functoid can be useful in a number of ways, but it is somewhat more complicated to set up correctly than many other functoids.For more information about the Looping functoid, see the Looping Functoid.
Under certain conditions, some functoids might not behave as expected when they are used in a map with a Looping functoid. If a functoid meets the following conditions, it does not produce the expected results when used with the Looping functoid:
The functoid has more than one input link.
Two or more of the functoid input links are linked to child fields of the input records to the Looping functoid, where the child fields are not siblings.
The functoid has an output link that is linked to a child field of the output record of the Looping functoid.
There is a logical filter in effect that makes the loop occur only when the logical condition evaluates to True.
Note: The Looping functoid should not be used with the Value Mapping (Flattening) functoid. If both are used together, it results in a compiled map that assumed there is no source looping dependency for the target nodes that are below the Looping functoid.
Source Schema:
- <ns0:StoreDetails xmlns:ns0="http://BTSMar13.LoopingSource">
<StoreNumber>001</StoreNumber>
<StoreName>Chicago</StoreName>
- <Orders>
- <Order>
<OrderType>Cash</OrderType>
<OrderName>Waterbottle</OrderName>
<OrderDate>2013-01-01</OrderDate>
</Order>
- <Order>
<OrderType>Card</OrderType>
<OrderName>WaterCan</OrderName>
<OrderDate>2013-01-02</OrderDate>
</Order>
- <Order>
<OrderType>Check</OrderType>
<OrderName>Watertank</OrderName>
<OrderDate>2013-01-03</OrderDate>
</Order>
</Orders>
</ns0:StoreDetails>
Destination Schema:
- <ns0:OrderDetails xmlns:ns0="http://BTSMar13.LoopingDest">
- <Order>
<StoreNumber>001</StoreNumber>
<StoreName>Chicago</StoreName>
<OrderType>Cash</OrderType>
<OrderValue>Waterbottle</OrderValue>
<OrderDate>2013-01-01</OrderDate>
</Order>
- <Order>
<StoreNumber>001</StoreNumber>
<StoreName>Chicago</StoreName>
<OrderType>Card</OrderType>
<OrderValue>WaterCan</OrderValue>
<OrderDate>2013-01-02</OrderDate>
</Order>
- <Order>
<StoreNumber>001</StoreNumber>
<StoreName>Chicago</StoreName>
<OrderType>Check</OrderType>
<OrderValue>Watertank</OrderValue>
<OrderDate>2013-01-03</OrderDate>
</Order>
</ns0:OrderDetails>