cancel
Showing results for 
Search instead for 
Did you mean: 

Udf for context change

Former Member
0 Kudos

Hi All,

I write a UDF to change context but it is not working properly

can any please guide me. code is ,

for (int i = 0 ; i<Plant.length ; i ++)

{

int b = 0;

for (int j = 0 ; j<Plant.length ; j++)

{

if (i!=j)

{

if (Plant<i>.equals(Plant[j]) )

{

b++;

}

}

}

if (b > 0 )

{

result.addValue(ResultList.CC);

}

else

{

result.addValue ("true") ;

}

}

In this code it is working for 'result.addValue ("true")' but not for 'result.addValue(ResultList.CC)'

Can any one tell me where is a problem?

---Rohit

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

try this

result.addContextChange(); instead of result.addValue(ResultList.CC);

Former Member
0 Kudos

Hi Shabarish Vijayakumar,

thank you for your reply, I also try result.addContextChange(), but the output is remains same i.e suppress. do you have any idea regarding this.

-


Rohit

stefan_grube
Active Contributor
0 Kudos

That should be no difference.

Answers (4)

Answers (4)

justin_santhanam
Active Contributor
0 Kudos

Rohit,

I've doubt that the condition for true is not satisfied and it always goes to else block.

Add MappingTrace to your code and check if its going to the If block or always it goes to esle block.

One more thing what is this operator for (int j = 0 ;<b> j><Plant.length</b> ; j++) ? What r u trying to achieve...

-raj.

Former Member
0 Kudos

The if / else statement is out of your for loop. Is it correct? I don't understand what your UDF should do, maybe you can give an example of your Plant[] string list and what you'd expect.

if (b > 0 )

{

result.addValue(ResultList.CC);

}

else

{

result.addValue ("true") ;

}

Former Member
0 Kudos

Hi Rohit,

As earlier mentioned to add context change you need to :

result.addContextChange();

Regards,

Sumit

stefan_grube
Active Contributor
0 Kudos

Could you decribe what you expect with an XML example?

And what do mean with "not working"?

Stefan