Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
BizTalk Books!
Custom Pipeline Components - part 3: Completing the Archive Component

A Custom Functoid - EBCDIC to ASCII

Posted by Andrew Babiec on December 20th, 2006

Here is an example of a custom functoid method that converts an EBCDIC signed value to ASCII format:

Add a new C# class library project to your BizTalk solution and call it MyCompany.BizTalk.Functoids. Create a C# class in the project and use the same project name for the namespace.

 Example:

using System;

using System.Collections.Generic;

using System.Text;

 

namespace MyCompany.BizTalk.Functoids

{

    /// <summary>

    /// Summary description for Utils.

    /// </summary>

    public class Utils

    {

        public Utils()

        {

 

        }

Add the method to perform the conversion:

/// <summary>

        /// Convert EBCDIC signed values to ASCII format

        /// </summary>

        /// <param name=”amount”>Amount to be converted</param>

        /// <param name=”sign”>Signed Value</param>

        /// <returns></returns>

        public double ConvertFromEBCDIC(double amount, string sign)

        {

            switch (sign)

            {

                case “{”:

                    amount = (amount / 10);

                    break;

                case “}”:

                    amount = (amount / 10) * -1;

                    break;

                case “A”:

                    amount = (amount / 10) + .01;

                    break;

                case “J”:

                    amount = ((amount / 10) + .01) * -1;

                    break;

                case “B”:

                    amount = ((amount / 10) + .02);

                    break;

                case “K”:

                    amount = ((amount / 10) + .02) * -1;

                    break;

                case “C”:

                    amount = ((amount / 10) + .03);

                    break;

                case “L”:

                    amount = ((amount / 10) + .03) * -1;

                    break;

                case “D”:

                    amount = ((amount / 10) + .04);

                    break;

                case “M”:

                    amount = ((amount / 10) + .04) * -1;

                    break;

                case “E”:

                    amount = ((amount / 10) + .05);

                    break;

                case “N”:

                    amount = ((amount / 10) + .05) * -1;

                    break;

                case “F”:

                    amount = ((amount / 10) + .06);

                    break;

                case “O”:

                    amount = ((amount / 10) + .06) * -1;

                    break;

                case “G”:

                    amount = ((amount / 10) + .07);

                    break;

                case “P”:

                    amount = ((amount / 10) + .07) * -1;

                    break;

                case “H”:

                    amount = ((amount / 10) + .08);

                    break;

                case “Q”:

                    amount = ((amount / 10) + .08) * -1;

                    break;

                case “I”:

                    amount = ((amount / 10) + .09);

                    break;

                case “R”:

                    amount = ((amount / 10) + .09) * -1;

                    break;

            }

 

            return amount;

        }

 

Add the close braces for the class and namespace, save the file and compile the project.

In order to use the scripting functoid in your map, you will need to first add the assembly to the GAC:

gacutil /i MyCompany.BizTalk.Functoids.dll

In order to use it on a map, you will need to drop the Scripting Functoid onto the map. It looks like a orange box with a S label. Select the scripting functoid and in the properties, click on the Configure Functoid Script option. A Configure Functoid Script dialog box will appear and the following entries should be filled in as follows:

Script Type: External Assembly

Script Assembly:  MyCompany.BizTalk.Functoids, version=…

Script Class: MyCompany.BizTalk.Functoids.Utils

Script Method: ConvertFromEBCDIC

After this, all you would need to do is connect the input parameter and the one output parameter.



Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!