cancel
Showing results for 
Search instead for 
Did you mean: 

UDF

praveenreddy_bk
Participant
0 Kudos

if Blank or non numeric or other than 1,3,12,13

raise error

Thanks in Advance

Accepted Solutions (0)

Answers (4)

Answers (4)

rajasekhar_reddy14
Active Contributor
0 Kudos

He praveen,

prasanna code will works fine,still u struck with this issue??

regards,

raj

prasannakrishna_mynam
Contributor
0 Kudos

Hello Praveen,

You can use the following condition to check all the 3 constraints.

Input String 'a'.

if( a.length()!=0 && !a.matches("\[0-9\]") &&

(a.equals("1") || args[0].equals("12") ||args[0].equals("13"))){

return a

}else{

throw new RuntimeException("Your Exception");

}

(or)

if( a.length()!=0 && a.matches(" \ \ d*") &&

(a.equals("1") || args[0].equals("12") ||args[0].equals("13"))){

return a

}else{

throw new RuntimeException("Your Exception");

}

Former Member
0 Kudos

Hi,

Additionally, to check for non numeric, use the following code.

try

{

int i = Integer.parseInt(inputSTR)

}

catch(NumberFormatException n)

{

throw new RuntimeException("Number Format Exception");

}

Hope this helps.

Thanks and Regards,

Kalpesh

justin_santhanam
Active Contributor
0 Kudos

Praveen,

Since you need only 1,3,12,13 to be passed successfully, you can use the below code.

input -a


if(a.equals("1") || a.equals("3") || a.equals("12") ||a.equals("13"))
{
return a;
}
else
{
throw new RuntimeException("Your Error exception");
}

raj.