on 10-07-2008 7:31 AM
Hi All,
My source field is of the format N(13,3) , (A Numeric field of lenth 13, out of which last 3 are decimal places and no decimal point ). I need to insert decimal point and map it to the Target Field.
if the input is 1234567890123 then output should be 1234567890.123
if it is 12345 then 12.345
Is it possible with formatNum function? If so, pls tell the parameters to be given for the function.
Hi,
Use this UDF and your porblem will be solved..
see the link for results
http://www.flickr.com/photos/23639237@N02/2920517443/
Under Imports: java.math.BigDecimal;
if( ! a.equals(""))
{
BigDecimal bigA = new BigDecimal(a);
BigDecimal result = bigA.movePointLeft(3);
return result.toString();
}
return "000";
Regards,
Sarvesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
I wondered wheter it might b possible with ### of formatNum function. I have used a UDF now.
Thanks for all your valuable responses.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ya,Sarvesh is right.
Arithmetic function jst rounds when large numbers r given.
Better try the below udf
Use cache parameter as Value.
1.
public String div(String a,Container container)
{
//write your code here
double b = Double.parseDouble(a);
double c = b / 1000;
String output = Double.toString(c);
return output;
}
or
2.
public String place_decimal(String a,Container container)
{
//write your code here
String output = a.substring(0,(a.length()-3)) + "." + a.substring(a.length()-3);
return output;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
most of actual XI/PI systems should be XI 3.0 SP 18 or PI 7.0 SP 9. In this case it's possible to use the div function. Only necessary step is to set the parameter com.sap.aii.mappingtool.flib3.bigdecimalarithmetic in exchange profile to true like mentioned in the blog above. BTW this should be done anyway.
Regards
Patrick
Hi,
>Is it possible with formatNum function?
No! This is not possible
If you have for example 12345 your output will look like 12345.000
(maybe even with some leading zeroes).
Easiest solution is the one suggested by malini balasubramaniam to divide the input with 1000.
But you should do it this way if you yould be sure that your input is always numeric and you have at least XI 3.0 SP 18 or PI 7.0 SP 9.
Otherwise go for an UDF (then you could check for a numeric value).
Regards
Patrick
Edited by: Patrick Koehnen on Oct 7, 2008 9:46 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
using UDF:
Input be A
Output be B
A1 = A.substring(0,(A.length()-3));
A2 = A.substring(A.length()-3);
B = A1 + "." + A2;
or through mapping :
input divide by 1000 = output
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can divide the number by 1000 to achieve this na.
src--------------------\
div--------->tgt
constant[1000]---/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
write this simple UDF to achieve this
str1 is input parameter to be operated
str2 = str1.substring(str1.length()-3); // taking out last 2 for decimal places
str3 = str1.substring(0,(str1.length()-3)); // taking rest of the string
return str3 + "." + str2;
this can also be done using graphical mapping by combination of substring,cocat, etc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.