cancel
Showing results for 
Search instead for 
Did you mean: 

Abs Function is not working for converting the negitive valies

Former Member
0 Kudos

Hi ,

My requirement is from the sorce I'm getting Amount data (both negative and possitive values)

if the value is negative then i want to convert it as possitive value. that means always i want to pass possitive values to my target side.

For this i have used ABS function AMOUNT (Source) ---> abs -


> AMOUNT (Target)

but now the problem is from the source I'm getting this value <AMOUNT>60179010.00</AMOUNT>

but while mapping it is converting and giving as <AMOUNT>60179008</AMOUNT>

I didn't understand this functinality . actually Abs function should just convert the sign of the value but why the value is also giving as mismatch.

please suggest me some solution for this..

Regards

jain

Accepted Solutions (1)

Accepted Solutions (1)

santhosh_kumarv
Active Contributor
0 Kudos

Hi Jain,

Yes. XI responds with a incorrect value.

Which SP are you in. This bug have been fixed in SP18. Have a look at this blog [Never, ever use XI's built-in arithmetic functions|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3446] [original link is broken] [original link is broken] [original link is broken];. it should help u.

Also have a look at this [New Arithmetic and Statistical Functions in Message Mappings in SP18|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4277] [original link is broken] [original link is broken] [original link is broken];

Thanks,

SaNv...

Former Member
0 Kudos

Dear Shabarish and Santosh ,

Thanks for your information. I'm using PI 7.0 and my SP --12 ... so, is this is a bug or any other problem. please confirm me so that i will go for the upgrade of SP.

Regards

Jain

Shabarish_Nair
Active Contributor
0 Kudos

yes. it is a known bug

you can create a UDF for the time being until the upgrade is done.

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

It is a Bug.. for now you could use the folllowing UDF.

public String absn(String a,Container container)
{
BigDecimal bigA = new BigDecimal(a);
return bigA.abs().toString();
}

import: java.math.BigDecimal;

Thanks,

SaNv...

Edited by: Sãnthosh Kûmãr V on Mar 10, 2009 5:07 PM

Answers (4)

Answers (4)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

This can be done without using UDF. you can use this mapping:


source --> replaceString --> Target Node
Constant: - -->  /
Constant:   --> /

Hope this helps,

Regards,

Former Member
0 Kudos

HI Jain,

Write an UDF for ABS function with this code,

double ret = Math.abs(Double.parseDouble(a));

return new java.math.BigDecimal(Double.toString(ret)).toString();

Try this. Hope it helps.

Shabarish_Nair
Active Contributor
0 Kudos

What SP are you on?

There have been lot of bugs in terms of the arithmatic functions in XI. But most of the issues have been solved in this release - http://help.sap.com/saphelp_nw04/helpdata/en/44/a7b4355d867455e10000000a11466f/content.htm

I suggest in case u are not on that SP upgrade to it or use a simple java UDF to do the abs conversion.

The math class in java can help you - http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html

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

former_member206760
Active Contributor
0 Kudos

Dear Jain,

I tried it in my server and it is working fine.

Pl chk again