cancel
Showing results for 
Search instead for 
Did you mean: 

java user defined function

Former Member
0 Kudos

Hi,

We have written a user defined function with the simple 'if' condition.

But the code will not be compiled without an 'else' statement.

What if we do not want to return any values for the else condition.?

See our simple code below

if (a.equals("AG") && b.equals("Y990028") && c.equals("A3"))

return "X1";

else if (a.equals("AG") && b.equals("Y990033") && c.equals("A3"))

return "X2";

else if (a.equals("AG") && b.equals("Y990108") && c.equals("A9"))

return "X3";

It is giving an error since there is no else condition.

We do not want to generate the element for an else condition.

Please help.

Thanks,

John

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi john,

if you don't want to return any value for else condition then you can add the line:

else

return"";

**Reward points if helpful.

--Sankar Choudhury

Former Member
0 Kudos

Hi,

We do not need to return a space.

The idea is not to generate the element at all.

Thanks,

John

Former Member
0 Kudos

Hi,

In User Defined Functions the Return value is must.

If you are using the If condition then there are chances to fail the conditions so at that time none of the return statement will be executed, thus it will request to add the else condition with Return statement.

Probably you could add the below statement in else condition. It will not affect you code and will server the purpose also.

else

return();

Thanks

Swarup

Former Member
0 Kudos

Hi,

maybe you could return a SUPPRESS value in the else condition.

Regards

Patrick

Former Member
0 Kudos

Hi,

We do not need to return a space.

The idea is not to generate the element at all.

Thanks,

John

Former Member
0 Kudos

Hi,

> The idea is not to generate the element at all.

thats why i said SUPPRESS.

try it with:

>else

>return ResultList.SUPPRESS;

/people/stefan.grube/blog/2006/01/09/the-use-of-suppress-in-the-xi-30-graphical-mapping-tool

Regards

Patrick

Edited by: Patrick Koehnen on Apr 9, 2008 1:26 PM