Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2010 Recipes : Document Mapping - Using the Date and Time Functoids

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
3/28/2011 9:53:58 PM

1. Problem

You are mapping a message in BizTalk Server and need to manipulate date and time fields. Specifically, you must use the current date in order to determine a required date and time in the future, which is added to the outbound message during mapping. Additionally, you must apply the processing time for each document during mapping.

2. Solution

Within a map, use the Date and Time functoids provided with BizTalk Server. To apply the current processing time to the outbound document within the map, take the following steps:

  1. Click the toolbox, and then click the Date and Time Functoids tab. On the map surface, in between the source and destination schemas, drag and drop a Date and Time functoid. Since this functoid simply outputs the current date and time, it requires no input values.

  2. Connect the right side of the Date and Time functoid to the element in the destination schema containing the date and time the message is processed.

To determine a future date based on the current date, take the following steps:

  1. Drag and drop a Date functoid from the Date and Time Functoids tab of the toolbox onto the map surface. This functoid is similar to the Date and Time functoid but returns only the current date, as opposed to the current date and time. It also requires no input values.

  2. Drag and drop an Add Days functoid from the Date and Time Functoids tab onto the map surface, positioning it to the right of the Date functoid. This functoid accepts two input parameters: a date or datetime value, and a numeric value indicating the number of days to add to the date supplied in the first input parameter. The return value is the date with the specified amount of days added.

  3. Connect the right side of the Date functoid to the Add Days functoid.

  4. Specify the second input parameter for the Add Days functoid as a constant with a value of 1.

  5. Connect the right side of the Add Days functoid to the element in the destination schema containing the future date.

3. How It Works

An example of a map that uses the Date and Time functoids is shown in Figure 1.

Figure 1. Using the Date and Time Functoids

This example captures the current date and time in the TransactionProcessingDateTime element, which is supplied by the Date and Time functoid. The format of the date and time produced by the Date and Time functoid is YYYY-MM-DDThh:mm:ss, which is ISO 8601-compliant. The time values are notated in 24-hour format.

The future date that the deposited funds will be available is captured in the FundsAvailableDateTime element. This value is based off the current date, supplied by the Date functoid, with a single day added to it to provide tomorrow's date, which is supplied by the Add Days functoid. The format of the Date functoid's output is YYYY-MM-DD, while the Add Days functoid accepts dates formatted as YYYY-MM-DD or YYYY-MM-DDThh:mm:ss. The format of the Add Days functoid's output is YYYY-MM-DD. All date formats used by these two functoids are ISO 8601–compliant. The time values are notated in 24-hour format.

The XML in Listing 1 represents one possible instance of the source schema.

Example 1. Sample Source Instance for the Date/Time Functoid Example
<ns0:ATMDeposit xmlns:ns0="http:// DateTimeFunctoids.ATMDeposit">
<ATMNumber>00111</ATMNumber>
<AccountNumber>123456</AccountNumber>
<Amount>100.00</Amount>
<Currency>USD</Currency>
</ns0:ATMDeposit>

When passed to the map in Figure 1, this XML message will produce the outbound XML document shown in Listing 2.

Example 1. Sample Output Instance for the Date/Time Functoid Example
<ns0:BankDeposit xmlns:ns0="http://Mapping.BankDeposit">
<TransactionSourceNumber>00111</TransactionSourceNumber>
<Account>123456</Account>
<Amount>100.00</Amount>
<Currency>USD</Currency>
<TransactionProcessingDateTime>2010-09-06T16:32:05</TransactionProcessingDateTime>
<FundsAvailableDateTime>2010-09-07</FundsAvailableDateTime>
</ns0:BankDeposit>


The Date and Time functoids provide a baseline set of functionality when needing to interrogate and manipulate date and time values. In the bank account example, the Date and Time functoid provides the current date and time, allowing a timestamp to be applied to the outbound document, indicating the time that the message was processed. Often, messages include an element or elements detailing the time that the message pertains to, or the time at which a message was created. The Date and Time functoid is useful when the actual processing time (in this example, the time a deposit is processed within a bank's integration system) is required, which will likely be different from any time value embedded in the source document. The difference between date and time values within a source instance message and the actual processing time of the message can be particularly important when dealing with batched or time-delayed processes.

This example also shows how you can use the Date and Add Days functoids in conjunction to calculate a future date based on the day a message is processed. The current date is provided by the Date functoid, which is used by the Add Days functoid to come up with a date that is a specified number of days in the future. In the bank account scenario, this functionality is used to determine the day on which deposited funds are available. Business rules like this can be common among financial institutions, as validation procedures are often required when dealing with monetary transactions.

NOTE

You can also use a negative numeric value with the Add Days functoid, resulting in a date that is the specified number of days in the past. For this example, the Date and Time functoid (substituting for the Date functoid) could have been used as the first input parameter for the Add Days function, and the map would be functionally equivalent. This is due to the fact that the Add Days functoid can accept either date or datetime values, and in either case, produces only a value indicating a date (excluding a time element).

This bank account example can be extended to illustrate how the Time functoid can be used to add a time component to the data capturing the date at which deposited funds are available. Currently, the example simply calculates a date for this value, but it is likely that a financial institution would additionally need to know the time at which deposited funds should be made available for use. Since the Add Days functoid produces only date values (without a time component), you must use a Time functoid, in addition to a String Concatenate functoid. To implement this enhancement, take the following steps:

  1. On the mapping grid, in between the source and destination schemas, drag and drop a Time functoid. Since this functoid simply outputs the current time, it requires no input values.

  2. Drag and drop a String Concatenate functoid onto the mapping grid. This functoid allows multiple string values to be concatenated, or added, together.

  3. Delete the current connection between the Add Days functoid and the element in the destination schema containing the future date that the deposited funds will be available in the bank account.

  4. Connect the right side of the Add Days functoid to the String Concatenate functoid.

  5. Specify the second input parameter for the String Concatenate functoid as a constant, with a value of T. This value is required in between the date and time portions of a datetime value for ISO 8601–compliant values.

  6. Connect the right side of the Time functoid to the String Concatenate functoid. The String Concatenate functoid should look like Figure 2.

    Figure 2. The String Concatenate functoid with time values
  7. Connect the right side of the String Concatenate functoid to the element in the destination schema containing the future date that the deposited funds will be available in the bank account.

Figure 3 shows an example of a map implementing these changes.

Figure 3. Using the Time functoid

Based on the same source XML used in the preceding example, the map in Figure 3 will produce the XML document shown in Listing 3, with a time component included in the FundsAvailableDateTime element.

Example 3. Sample Output Instance for the Time Functoid Example
<ns0:BankDeposit xmlns:ns0="http://Mapping.BankDeposit">
<TransactionSourceNumber>00111</TransactionSourceNumber>
<Account>123456</Account>
<Amount>100.00</Amount>
<Currency>USD</Currency>
<TransactionProcessingDateTime>2010-09-06T16:32:04</TransactionProcessingDateTime>
<FundsAvailableDateTime>2010-09-07T16:32:05</FundsAvailableDateTime>
</ns0:BankDeposit>


One common challenge when dealing with datetime values is standardizing on a common format. This issue can be seen with dates adhering to the MM-DD-YYYY (common in the United States) or DD-MM-YYYY (common in Europe and other areas) format. Unfortunately, BizTalk Server does not have any Date and Time functoids that do complex datetime formatting. There are a number of ways to handle this issue. The simplest way is to use string functoids provided with BizTalk Server to manipulate and standardize the order of year, month, and day values. Specifically, you can use String Extract functoids to pull out values within a date (in this scenario, you would pull out the DD, MM, and YYYY values in three separate String Extract functoids), and then a String Concatenate functoid to combine the individual values in the correct format (in this scenario, you would append the three values in an order of YYYY-MM-DD).

There are also more robust ways of implementing complex date/time formatting. One option is to use the Scripting functoid, which provides access to the libraries of C#, VB .NET, and JScript .NET (either via inline code embedded in the map, or by referencing external assemblies written in one of the .NET-compliant languages). Additionally, you could use a custom functoid (which would leverage the datetime functionality of a .NET language).
Other -----------------
- BizTalk 2010 Recipes : Document Mapping - Creating a Custom Functoid
- Windows Server 2008 R2 : Deploying and Using Windows Virtualization - Using Snapshots of Guest Operating System Sessions
- Windows Server 2008 R2 : Deploying and Using Windows Virtualization - Launching a Hyper-V Guest Session
- Windows Server 2008 R2 : Deploying and Using Windows Virtualization - Modifying Guest Session Configuration Settings
- Windows Server 2003 : Using Network Load Balancing (part 2) - Deploying a Network Load Balancing Cluster & Monitoring Network Load Balancing
- Windows Server 2003 : Using Network Load Balancing (part 1) - Planning a Network Load Balancing Deployment
- Exchange Server 2010 : Securing POP and IMAP Exchange Server Traffic
- Securing Exchange Outlook Web App with ISA Server 2006 (part 2) - Creating an Outlook Web App Publishing Rule
- Securing Exchange Outlook Web App with ISA Server 2006 (part 1) - Exporting and Importing the OWA Certificate to the ISA Server
- Leveraging Social Networking Tools in SharePoint 2010 : Restricting User Access to and Creation of My Site Sites
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
 
programming4us
Natural Miscarriage
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Game Trailer