on 08-30-2007 12:31 AM
Hi All,
The incoming field in XI is 163.63-
I need to write a UDF to covert the string to -163.63.
How do I write the same..
XIer
Hi Xler,
Here i am giving UDF code, This outputs positive value(163.63) if input value is positive (163.63)
and negative value as -163.63 if input is 163.63
Just create <b>Value</b> UDF by passing filed which contains this value as input
if(a.endsWith("-"))
{
a = a.replace('-',' ');
a = "-" + (a.trim());
return a;
}
else
return a;
Please let me know if there are any issues regarding this code.
Cheers,
Jag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
XIer,
Please follow the code.
import java.util , in or udf import parameters. Conisder input as ur argument name.
int cnt =input.indexOf("-");
String result="";
if(cnt ==-1)
{
return ""+input+"";
}
else
{
StringTokenizer st = new StringTokenizer(input,"-");
result = "-"+st.nextElement().toString();
return ""+result+"";
}
-raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
XIer,
Do u want to use them inside ur program after converting into negative value or just passing to the target system. Also only u need to convert if you have the negative symbol on the end or for all the value.
Example:
189.90- then convert to -189.90
134.50 then the value must be 134.50 ,
Is my above understanding is correct?
-raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.