Microsoft BizTalk Server 2004: Creating a Schema Map - Exercise 2: Adding Functoids to a Map (Page 3 of 4 ) Scenario In this exercise, you will add functoids to transform a value from a field in the source schema to a field in the destination schema. Tasks | Detailed steps | Add a cumulative functoid to the map.
This functoid calculates the total quantity of all line items in the customer order before updating the total quantity in the purchase order.
| In the Toolbox, click the Cumulative Functoids palette, click the Cumulative Sum functoid, and then drag it to the Mapper grid. In the Source Schema pane, click the Quantity field, and then drag a link to the Cumulative Sum functoid in the Mapper grid. In the Mapper grid, click the Cumulative Sum functoid, and then drag a link to the TotalQty in the Destination Schema pane.
| Add a multiplication functoid to the map.
This functoid calculates the total cost of a line item.
| In the Toolbox, click the Mathematical Functoids palette, click the Multiplication functoid, and then drag it to the Mapper grid. In the Source Schema pane, click the UnitPrice field, and then drag a link to the Multiplication functoid in the Mapper grid. In the Source Schema pane, click the Quantity field, and then drag a link to the Multiplication functoid in the Mapper grid.
| Add another cumulative functoid to the map.
This functoid calculates the total cost of all line items in the customer order before updating the total cost in the purchase order.
| In the Toolbox, click the Cumulative Functoids palette, click the Cumulative Sum functoid, and then drag it to the Mapper grid.
Make sure to place this functoid to the right of the multiplication functoid. Functoids must always link from left to right. In the Mapper grid, drag a link from the Multiplication functoid to the Cumulative Sum functoid in the Mapper grid. In the Mapper grid, drag a link from the Cumulative Sum functoid to the TotalCost field in the Destination Schema pane.
| Add a scripting functoid to a map.
This step changes the value in the Priority field from an integer to a string. This function could be written in C#, Jscript.NET, XSLT, or an external assembly.
| In the Toolbox, click the Advanced Functoids palette, select the Scripting functoid, and then drag it to the Mapper grid. In the Source Schema pane, click the Priority field, and then drag a link to the Scripting functoid in the Mapper grid. Click the Scripting functoid, and then drag a link to the Priority field in the Destination Schema pane. Select the Scripting functoid, and press F4 (this brings up the Functoid Properties window). Select the Script property, and then click the ellipsis (…) button. In the Configure Functoid Script dialog box, in the Script type drop-down list, select Inline Visual Basic .NET, and then type the following code in the Inline script buffer text box: Public Function PriorityConversion(ByVal param1 As String) As String Select param1 Case “1” Return “High” Case “2” Return “Medium” Case “3” Return “Low” Case Else Return “Error” End Select End Function
Click OK to save the script and close the Functoid Properties window.
The completed map should look similar to this: 
| Create a new map page.
It is not required to create a new page but it will aid in readability.
| Below the Map Zone, right-click the Data Maps tab, click Add Page to create a new page (or map zone), and then rename the page as Control.
| Add a Looping functoid to the map.
This functoid loops through all occurrences of line items in the customer order and creates multiple line items in the purchase order.
If no Looping functoid is present, the Mapper will try to determine how many of the destination nodes to create for each occurrence of the source node. Even if the Mapper chooses the looping that you desire, it is best for documentation purposes to explicitly use the Looping functoid.
| In the Toolbox, click the Advanced Functoids palette, and then drag the Looping functoid to the Mapper grid on the Control page. In the Source Schema pane, click the SalesOrderLine record, and then drag it to Looping functoid in the Mapper grid. In the Mapper grid, drag a link from the Looping functoid to the Item record in the Destination Schema pane.
The completed map should look like this: 
On the File menu, click Save All.
|
Next: Exercise 3: Validating and Testing the Map >>
More BrainDump Articles More By MSDN Virtual Labs |