cancel
Showing results for 
Search instead for 
Did you mean: 

Msg Mapping :: Converting String ( source ) to double ( target ) Type

Former Member
0 Kudos

Hi

During my message mapping, I have to convert one String Field from Source Structure to Double ( primitive data type ) field in Target Structure.

String Weight -


Source

Double Wght -


Target

      • Java Code ****

<b>double Wght = Double.valueOf(Weight.trim()).doubleValue();</b>

But if I use this in UDF then it has default return type as String.

Can I change the return type in UDFs or is their any other way using which I can do this conversion.

Best Regards

- lalit chaudhary -

Accepted Solutions (0)

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

Inside XML there are only strings.

When in the target structure it is mentioned to have a double, that menas that inside the XML there has to be a string representation of a double value.

This can be any number.

When the sourc provides a number, you need not care about this at all.

Regards

Stefan

Former Member
0 Kudos

Hi Lalit,

I think XI takes care of type conversions internally. So you can just do a one-to-one mapping and try executing the scenario.

Regards,

P.Venkat

Former Member
0 Kudos

In XI mapping, source and target field is always String, by default, left justify.

and the user defined function can only return string type, but if you want a special numberic format, there is a fuction to format number, you can use.

--wenning

Former Member
0 Kudos

Wenning

My question is not to convert the " Number Format " for which XI has Standard Function " <i>FormatNum</i> ".

But I would like to convert String to double, which is the conversion of Data Type.

- Lalit -

Former Member
0 Kudos

the user defiend fuction only return string type, and the target XML only take String value in each field, I am a little bit confused why you use double type for? Maybe that is the key question we need to understand your issue and see any walk around.

--Wenning

Former Member
0 Kudos

As my receiver Business System is WebService & in their WSDL file the Weight field is of double type.

And in Sender SAP System the standard field for Weight is of type String.

Now can't change the types of these fields. So looking for conversion solution within XI.

- Lalit -

Former Member
0 Kudos

As long as you make sure you map a double value to the WSDL weight field from your source xml(be it string or any type), your web service call should work. Are you facing issues at the reciever system because of this ? Have you tried calling web service without this conversion ?

Former Member
0 Kudos

Hi Lalita,

Please see the following code try..

static public double parseDouble(String s)

{

return doubleValueOf(s);

}

But XI always input ,output as string in MM.

is it your requirement..?

Regards

Chilla..

Former Member
0 Kudos

Lalit,

You need not write any code for the conversion. If you have double in target data type, Xi will map the source value (what ever it is) to the double value. But you have to ensure you are passing a double value. Suppose if the source is 10.00 then it is not a problem. But if you are passing 10, XI will pass only 10 to the target. You should handle this.

Regards,

Jai Shankar

Former Member
0 Kudos

Sorry for updating this thread late.

Sender System was passing the <b>"NULL"</b> value for double field. Now I am checking this in mapping in case if they pass NULL I am providing default value as 0.

Thanks everyone

- Lalit -