How to take leading zeros from a string in BizTalk mapper

Home Page Forums BizTalk 2004 – BizTalk 2010 How to take leading zeros from a string in BizTalk mapper

Viewing 2 reply threads
  • Author
    Posts
    • #22182

      Hi I have a scenerio where from a source schema element which is a string has “001” I need to remove the Zeros and map to the destination element as “1”  and if it has “010” then it should be set as “10”, the destination element is also string. How do I acheive this in BizTalk Mapper.

      For the above scenerio I tried by writing VB code and I have assigned the string like this 

      cmd.Parameters(

      “@String”).Value = inputstring.PadLeft(3, “0”c).ToUpper()

      but its not working

      Does anyone have an idea about this.

      Thanks in Advance

    • #22184

      How about using the Math Add functoid and add zero to this value

      • #22218

        Hi, – he wants to remove leading zeroes, not to add. [:)]

        • #22409

          [quote user="Zx7R"]

          Hi, – he wants to remove leading zeroes, not to add. Smile

          [/quote]

          The Math Add functoid will convert the string into a number add zero (number is unchanged) and outputs the number as a string without leading zeros.
          This approach is easier than the custom functoid if you have a lot numbers in a message you need to convert. With the scripting functoid approach you will need a scripting functoid for each number, each with a different method name. Likewise, in an orchestration you could end up with a lot of xpath statements/distinguished fields to manage.   

      • #22403

        Great, this works nice[<:o)]

      • #25170

        Great Solution yaar, its working fine

    • #22217

      Hi,

      1. You can use inline code in scripting functoid, and to replace every leading  zeroes by empty string, and all that in a loop.

      2. If you don’t wish use functoid – create a class and pass the string as a parameter in an orchestration, and all logic will sit in your external assembly.

       

Viewing 2 reply threads
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.