Skip to Content
author's profile photo Former Member
Former Member

message mapping between the string and decimal

Hi ALL,

I have a requirement were have to map between the idoc and xsd.

the problem I'm facing while mapping is the data type conflict. since both side(source and target) are standard, so can't change the data type .

the source is a string and target side we have decimal.

we are mapping source_element(string) to dest_element(decimal) and error mapping not possible.

so if anyone know the solution for this please let me know.

Thanks in Advance,

Lalit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Sep 07, 2010 at 07:02 AM

    Hi,

    First convert string to decimal using UDF,then map UDF out put to target.

    search in google for java code to convert string to decimal.

    or

    if your bussiness people accpets string value at target side means,change xsd filed type to string in XSD,this will solve your problem too..

    but i prefer first one.,

    Regards,

    raj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2010 at 07:16 AM

    What is the exact error you are getting?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2010 at 07:19 AM

    Hi,

    You can write a UDF to do this for you.

    Execution type: Single values.

    Under Signature variable:

    Argument var1 string

    Code:

    String s = var1

    try

    {

    float f = Float.valueOf(s.trim()).floatValue();

    }

    catch (NumberFormatException nfe)

    {

    System.out.println("NumberFormatException: " + nfe.getMessage());

    }

    return f;

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2010 at 09:06 AM

    No matter what you have in XSD, the XML representation of any type is a String.

    So all you have to do is to make sure that your target has correct format 1234.56

    When your input value has another foramt like 1,234.56 or 1.234,56 you can have the correct output with easy string manipulations (replaceString)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.