BizTalk Mapper

BizTalk Mapper allows you to map fields and records from one specification to fields and records in another specification. BizTalk Mapper uses links and functoids. A link is a simple copy operation from the value in one field to the value in another field. A link can also copy to a functoid. A functoid is an object that allows for complex structural manipulation operations between source elements and destination elements. Before a specification can be used in BizTalk Mapper, it needs to be defined in the BizTalk Editor. BizTalk Mapper supports EDI, flat files, XML files, schemas, and even ADO recordsets. BizTalk Mapper can also create XSL style sheets for mapping.

As an example of how to use BizTalk Mapper, we will use two PO specifications that come with BizTalk Server 2000. To see how BizTalk Mapper works, follow these steps:

  1. Click the Start button, point to Programs, Microsoft BizTalk Server 2000, and then choose BizTalk Mapper.
  2. From the File menu, choose New. You will see the Select Source Specification Type screen where you can choose either Local Files, which is a specification on your local computer or network; Templates, which are templates that came with BizTalk Server; or WebDav (Web Distributed Authoring and Versioning) Files, which refers to specifications on shared servers. For our example, we will imagine that we are transferring a purchase order file from a local XML file to an XML purchase order file located in a common WebDav location.
  3. In the Select Source Specification Type screen, click Templates, choose XML, and then choose CommonPO.xml. You will now see the Select Destination Specification Type screen.
  4. For the destination, choose WebDav Files. The Retrieve Destination Specification screen will appear. In this screen choose Microsoft, and then choose CommonPO.xml. In this case, both specifications use fields with the same name. In other cases, the fields might have completely different names.
  5. Expand the POHeader on both the source specification and destination specification. You can see the fields contained in the POHeader. Drag the Purpose field from the source to the destination. The map should now look as shown in Figure 16-4.

By connecting source and destination fields, you can create a map between a source and a destination specification. If you now connect other fields, you can go to the Tools menu and choose Compile Map to produce XSL code that will create the transformation between the two specifications. Figure 16-5 shows the XSL code generated in the Output tab on the bottom of the BizTalk Mapper after linking several other fields and then compiling.

Figure 16-4. Microsoft BizTalk Mapper.

Figure 16-5. The Output tab showing the XSL code after compiling.

As mentioned, you can use functoids to perform complex structural transformations between source elements and destination elements. Functoids use predefined formulas and specific values to perform calculations. You can select functoids from the Functoid Palette. To work with functoids, follow these steps:

  1. On the View menu, choose Functoid Palette to open the Functoid Palette screen.
  2. From the Functoid Palette screen, you can choose a functoid and drag it to the mapping grid area. The mapping grid area is the gray grid area between the source and destination in Microsoft BizTalk Mapper. As an example, select the Mathematical tab of the Functoid Palette screen, click the X (multiplication) functoid, and drag the X onto the grid. Connect a field to the functoid, right click the functoid, and then select Properties to open the Functoid Properties window. In this window, select the Script tab. You can see that a function is created in this tab, as shown in Figure 16-6.
  3. Figure 16-6. The Script tab in the Functoid Properties window.

In our case, the function FctMathMultiply1 is defined in the following code:

  Function FctMathMultiply1( p_strParm0 )
    If ( IsNumeric( p_strParm0 ) ) Then
    FctMathMultiply1 = CStr ( CDbl( p_strParm0 ) )
      FctMathMultiply1 = ""
    End If
  End Function

As you can see, the function is just a template. You will need to fill in the necessary functionality to make this function work. In the pre-release version of the BizTalk Mapper, this script cannot be edited in the Functoid Properties window. However, you can go to the Advanced tab of the Functoid Palette to edit the script. (You might need to scroll over to see the Advanced tab.) Get the Custom Visual Basic Script from the Advanced tab and drop it on the grid, make a connection from a field in the source document to a field in the destination document, and then edit the script. A custom transformation will be created between the source field and the destination field.

As you can see, functoids make it easy to do transformations. When the map is compiled by choosing Compile Map from the Tools menu, the XSL script will include functions to perform these transformations.

by BrainBellupdated