Regex on an element field and its datatype

Home Page Forums BizTalk 2004 – BizTalk 2010 Regex on an element field and its datatype

Viewing 1 reply thread
  • Author
    Posts
    • #25422

      I have a .csv file in which entries come in this format: $9,000,($9,000) –  the second one being a negative one viz -$9,000. The .csv file upon formatting yields the values as above. I want to make the schema for this fields. I have made use of certain Regex expressions. Just wanted to know whether it is proper to set the datatype of the mentioned fields as int? Is this method correct and will it be processed by BizTalk server?

    • #25426

      Hi Abhishek:

       

         Are you creating a schema in BizTalk based on the CSV file? If so, then try setting the datatype to xs:string for the fields that will hold the currency values (e.g.   $9,000 ,  ($9000) ) and see if that works.

       

         Daniel.

       

      • #25431

        Hello Daniel,

        I am building the schema from the csv file. But, i need to map it to a BAPI schema from SAP end and the corresponding currency fields in the BAPI schema will be ‘int’ datatyped. So, i’ve come to know that ‘int’ datatype on the field i mentioned isn’t possible and i’ll have to use it as a ‘string’.

        If so, before mapping, can i convert the field into int through a message assignment shape(one of my friends suggested this just now)?

        or

        is there any other method to achieve this?

        • #25435

          Hi Abhishek,

           

             You can also convert the field(s) to an integer datatype in a map that transforms your CSV schema to your BAPI schema. Is that not what you want?

           

             If you don’t want to use a map, if your field(s) are not Distinguished Fields, then you would have to use XPath expressions and System.Convert.ToInt32 function in a Message Assignment shape to do the conversion.

           

             Hope this helps,

           

             Daniel.

           

          • #25447

            Hello Daniel,

            That’s exactly what i want. But i don’t know how to achieve that through a map. Could you suggest some possible links  that can help me.

            And, now to the message assignment shape, i will have to scrap the ‘$’,'(‘,’)’ signs that i have associated with the fields. can they be directly done with help from Replace() function in the msg asgmnt shape?

            Another alternative i was thinking about is developing a custom functoid that will remove the mentioned signs and then convert the field to an ‘int’. How about that?

            Your posts do help. Thank you.

            • #25453

              Hi Abhishek,

               

                 The XLANGs syntax does not support any string Replace() function in a Message Assignment shape, so your best bet is to use a C# inline Scripting functoid in a map to do the following:

               

              1. Scrap the dollar sign, parentheses and comma characters in your fields.

              2. Convert the String value to an Int32 value and return that from the custom function in your functoid.

               

                 I hope this gets you on the right track.

               

                 Daniel.

               

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