on 01-21-2014 6:50 AM
Hi Experts ,
i need a udf to do the handle the following 3 types of data
Data of the below 3 types can come , i need to remove + or - if any , divide it by 100 and then add + /- based on the input data type ..
100- = needs to convert to 1-
500+ = needs to convert to 5+
2000 = needs to convert to 20
Please suggest probable UDF . String length can vary .
Thanks and Regards,
Arnab
Hi Arnab
Create an UDF like below
UDF
Execution type all values of a context
Input will be inputstr
code :
String newstr ="";
if(inputstr[0].indexOf("-") != -1 )
{
newstr = inputstr[0].replaceAll("-","");
newstr = Integer.toString(Integer.parseInt(newstr)/100)+"-";
}
else if(inputstr[0].indexOf("+") != -1 )
{
newstr = inputstr[0].replaceAll("\\+","");
newstr = Integer.toString(Integer.parseInt(newstr)/100)+"+";
}
else
{
newstr= inputstr[0];
newstr = Integer.toString(Integer.parseInt(newstr)/100);
}
resultAddvalue(newstr);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
U can use a combination of UDF and standard fucntions
UDF
Execution type all values of a context
Input will be var1
and add two Result type parameters result1 and result2
int len = var1[0].length();
String last = var1[0].substring(len-1,len);
if(last.equals("-") || last.equals("+"))
{
result1.addValue(var1[0].substring(0,len-1));
result2.addValue(last);
}
else
{
result1.addValue(var1[0]);
result2.addValue("");
}
Mapping:
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.