cancel
Showing results for 
Search instead for 
Did you mean: 

Return statement error

Former Member
0 Kudos

Hi

I wrote UDF to check the Amount value..But i am getting error Return statement } missing

My code is like

public String AmountValue(String a,Container container){

//write your code here

int i = Integer.parseInt(a);

if(i > 0)

i = 100;

else

throw new RuntimeException("Value should be Greater than zero");

}

venkat

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use this code - it will work

int i = Integer.parseInt(a);

if(i > 0)

i = 100;

else

throw new RuntimeException("Value should be Greater than zero");

return Integer.toString(i); // or return ""+i; or return "";

Regards,

Balaji.M

Answers (2)

Answers (2)

justin_santhanam
Active Contributor
0 Kudos

Venkatesh,

The above function will always throw an excepption. Use try catch block.

Best regards,

raj.

henrique_pinto
Active Contributor
0 Kudos

venkatesh,

you have to have a <b>return</b> statement in the UDF, when it is not of context or queue type.

Add this line to the end of your UDF:

return i;

Regards,

Henrique.