on 02-07-2008 10:00 AM
Hi Experts,
I have a strange error in mapping while using subtract function.
Field_A (20071001) - Constant (19000000) = Result (1071000)
The Result should be 1071001.
Check the screenshot of mapping.
http://docs.google.com/Doc?id=ddmc8m97_8gxczcgdt
Note:
--> I have tried the field as Integer, Float and String also, but same result.
--> It is not working for add function also, like
Field_A (20071001) + Constant (-19000000) = Result (1071000)
--> It is working fine for other values.
Please help me in this.
Regards,
Naveen Chamala
Hi Naveen!
Exactly! You're right! The function doesn't work properly.. I tried 3.06-3 and I got smth like 0.055555559 )
Well, I solved it with my own function:
double fa = Double.valueOf(a.trim()).doubleValue();
double fb = Double.valueOf(b.trim()).doubleValue();
return Float.toString((float)(fa-fb));
The problem in the "standard" function is probably in cast of values from one type to another.
Try some workaround with UDF.
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Naveen,
If I understand your requirement correctly, then there is no need to go for UDF. I have a solution and it's working perfectly.
lemme summarize my understanding:
1) you have an integer/string of 8 digits
2) you will be subtracting with a constant 19000000
3) so u will generate 7 digit integer/string
4) the end system will add 19000000 and they will get the date
solution is as follows:
1) the normal subtract function
2) check the out put is ending with '0' (endWith)
3) If it ends with '0'
4) then repeat ur first subtract function and add function to that with a constant '1'
5) else your normal subtract function.
I dn't know how to upload the link... hence forwarding the screenshots to ur mail id.
Regards
Hi vijaya,
I appreciate your effort in this mapping.
But everytime, whenever you require a sub. function simply u will use it. And it will work for your value.
Here It is not working for value (20071001). fortunately i have tested with this value.
As per basic mathmatics, 10-8=2, If XI says its not 8, it is 7 or something...do we need to use all these conditions for every no. ?
anyway, i am using the user defined function.
Regards,
Naveen
Hi Naveen,
this is a common problem when working with big numbers. I am using UDF also for adding(summing) big numbers and negating them.
import java.math.BigDecimal;
public void sumBig(String[] list,ResultList result,Container container){
BigDecimal tmp;
BigDecimal sum;
sum = new BigDecimal("0");
tmp = new BigDecimal("0");
for (int i = 1; i <= list.length; i++)
{
tmp = new BigDecimal(list[i - 1]);
sum = sum.add( tmp );
}
result.addValue( sum.toString() );
}
public String negBig(String x,Container container){
BigDecimal tmp;
tmp = new BigDecimal( x );
tmp = tmp.multiply( new BigDecimal("-1") );
return tmp.toString();
}
All,
The problem with SAP arithmetic functions is fixed in the following SAP Note: 958486
Solutions for older versions of XI/PI can be found in the blog: /people/thorsten.nordholmsbirk/blog/2006/04/03/never-ever-use-xis-built-in-arithmetic-functions
Hope this helps,
Matt.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The screenshot has the value 2007100 instead of 20071001 !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.