CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeff Lynch [MVP]

Everything E-Commerce!

BizTalk Server 2004: Business Logic in Maps

I realize that this breaks most of (if not all) the architecture rules we've come to cherish, but sometimes it's just more efficient (easier) to place a “little” business logic in your maps.

If you recall from my previous posts, I've been working to integrate purchase orders and invoices between our Houston, TX and Glasgow, Scotland facilities. Since the ERP systems involved already handle the currency translation, I thought everything else would fall into place pretty simply. At first glance it did but after more extensive testing, several other “little” issues came to light that required a quick and dirty approach to handle in a timely manner. Which really means the boss gave me less than one hour to get it fixed!

The problem was really pretty simple: one ERP system wanted to place it's purchase orders and receive it's products in kilograms (KG) and the other ERP system wanted to receive it's sales orders and ship it's products in pounds (LB). Not really a problem in the “paper” world but definitely an issue in the “electronic” world.

I found the easiest way to handle this was with a simple Scripting Functoid using Inline C# code as shown below. If the inbound unit-of-measure for the item is in kilograms, the script converts it to pounds. If the UOM is anything else, it doesn't. Simple, clean and efficient!

public string ConvertQty(string strQty, string strUOM)
{
    if(strUOM == "KG")
    {
        double dval = Convert.ToDouble(strQty, 
        System.Globalization.CultureInfo.InvariantCulture);
        return (dval*2.205).ToString("F");
    }
    return strQty;
}

 


Published Jan 26 2005, 03:59 PM by jlynch
Filed under:

Comments

Niklas E said:

System.Globalization.CultureInfo.InvariantCulture is that decimal . och decimal , or does invariant accept both?

We have difficulties in many integration projects, because swedish decimal is comma and US settings are point. In some systems there are both as well just to make it more fun.
# January 26, 2005 9:44 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

Our Sponsors

Free Tech Publications

This Blog

Syndication