cancel
Showing results for 
Search instead for 
Did you mean: 

Multiplication by -1 rounds the value.

Former Member
0 Kudos

Hi,

In message mapping i am using th NEG function to negative a all amounts. The problem is it rounds the amount,

eg.

212399.46 gets round to -212399.45

I tried the multiplication function as well and had written a JAVA function for the same all seems to give the same result.

after playing a lot with this issue i found that

The rounding of amounts is done only for amount with more than 5 digits before the decimals.

If the 1st decimal number is below 5 and the second is above 5. than the second decimal gets decremented by 1 e.g. 212399.46 gets round to 212399.45 exception to this is u201C.47u201D,u201D.48 u201C donu2019t know why

If the 1st decimal number is above 5 and the second is above 5. than the second decimal gets incremented by 1e.g 254398.76 gets round to 254398.77

Amounts in decimal number u201C.88u201D u201C.77u201D u201C.66u201D,never gets round of

Can any one help me with why it rounds values and provide a solution so that it does not rounds the value and pass amount just with negative sign without rounding.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

please have a look here:

/people/thorsten.nordholmsbirk/blog/2006/04/03/never-ever-use-xis-built-in-arithmetic-functions

/people/thorsten.nordholmsbirk/blog/2006/08/25/new-arithmetic-and-statistical-functions-in-message-mappings-in-sp18

Regards

Patrick

Former Member
0 Kudos

Hi Patrick,

Thanks for the help, I think I got my answer will give update the thread once this is solved.

Sachin

Former Member
0 Kudos

Hi,

It is pretty much straight.

Please try the java udf below.

String newStr = "-"+strInput;

BigDecimal bd = new BigDecimal(newStr);

Thanks

amit

Reward point if suggestion helps

Former Member
0 Kudos

Hi Amit,

I will have multiple amounts in the same context.

like

1234.56

2345.78

0.00

The output should be

-1234.56

-2345.78

0.00

no negative for 0.00

Sachin

Former Member
0 Kudos

HI Sachin,

Did u used any UDf for the same. if yes then in UDF what u can do is first check the value if the value is 0.00 then return the same.

check with if(a(i).equals("0.00"))

{

result.addValue(a(i));

}

else

{

ur logic for negative conversion.

}

chirag

}

Former Member
0 Kudos

Hi,

you can do this also with a standard if function:

if sourceValue > 0

then targetValue = concat (constant(-), sourceValue)

else sourceValue

Sorry forget that have more values in one context...

In this case you will need an udf.

So just use a combination of the udfs provided by Amit and Chirag and it should work.

Regards

Patrick

Edited by: Patrick Koehnen on Jun 27, 2008 6:15 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks Chirag, Amit and Patrick.

I will first fix the XI 3.0 bug for artithmatic function.

and check.

Definetly UDF is an always an alternative.

Points awarded to all of u.

Thanks

Sachin