on 02-03-2011 2:58 PM
Hi,
I would get the source quantity values as follows
88.000-
89.000
3000.00
My target field will accept only as whole numbers.
So, I would need to represent as follows
88-
89
300.
Though I use formatnum, it is failing when it is sent negative values.
Please help on this.
Use this UDF and it will solve your problem for sure.
Create Udf name as follows ...
Title: checkNegativeValue or your required name
Execution type single value
Signature variable
Type: argument Name: number java type: String
public String checkNegativeValue(String number, Container container) throws StreamTransformationException{
String minus="-";
String wholeNum="";
int index = number.indexOf(".");
if(number.endsWith("-")){
wholeNum = number.substring(0,index)+minus;
}else{
wholeNum = number.substring(0,index);
}
return wholeNum;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krish,
I have successfully tested this UDF,
public String GetInteger(String in_quantity, Container container) throws StreamTransformationException{
if(-1 != in_quantity.indexOf("."))
{
if(-1 != in_quantity.indexOf("-"))
{
return in_quantity.substring(0,in_quantity.indexOf(".")) + "-";
} else
{
return in_quantity.substring(0,in_quantity.indexOf("."));
}
} else
{
return in_quantity;
}
}
Regards,
Raghu_Vamsee
Edited by: Raghu Vamsee on Feb 3, 2011 11:33 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In a similar scenario i used a concat with a constant which had blank spaces with a - sign in the end and it worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try doing some operation like multiply or add to get removed the zeros...not sure..just a try..
Regards
Rajesh
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 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.