cancel
Showing results for 
Search instead for 
Did you mean: 

Quantity

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

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;

}

RaghuVamseedhar
Active Contributor
0 Kudos

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

Former Member
0 Kudos

In a similar scenario i used a concat with a constant which had blank spaces with a - sign in the end and it worked

Former Member
0 Kudos

Hi,

Try doing some operation like multiply or add to get removed the zeros...not sure..just a try..

Regards

Rajesh