cancel
Showing results for 
Search instead for 
Did you mean: 

CORRECTION IN UDF

vijender_p
Active Participant
0 Kudos

Hi all,

Actually i have build a logic in the mapping fora field .


In the which the logic is

If Employee Group (P0001-PERSG) = 9 (Non-Employee) & Employee Subgroup (P0001-PERSK) = 0F(Consultant) value should be Consultant

So for this i have written a udf

String tmp = "";

for (int i=0;i<=7;i++)

{

if (persg[i].equals("9")&&persk[i].equals("OF"))
{

tmp = "Consultant";

return tmp;

}
}

please correct me where i have actually missed the logic as it is not working.

Best Regards,

Vijender

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Vijender,


String tmp = "";

for (int i=0;i<=7;i++)

{

if (persg[i].equals("9")&&persk[i].equals("OF"))
{

tmp = "Consultant";

return tmp;

}
}

If you need to use a loop, the UDF should either be Queue type or Context type. There is no return because it is void. However, you can use resultList for that e.g without modifying the name of the output argument here is an updated code using Context type UDF:


for (int i=0;i<=7;i++){

     if (persg[i].equals("9")&&persk[i].equals("OF")){

          result.addValue("Consultant");

     }
}

Regards,

Mark

vijender_p
Active Participant
0 Kudos

Thanks a lot mark !!!


i got the logic !!!

best regards,

Vijender

Answers (2)

Answers (2)

vijender_p
Active Participant
0 Kudos

Hi all ,

can you please help me out in these logic

Regards,

maheswarareddykonda
Active Contributor
0 Kudos

try this logic.

Note:if values are coming in same context for both source files , you use Splitbyvalue(nodefunction) after those two source fields.

sahithi_moparthi
Contributor
0 Kudos

Hi,

Please use below Logic:

You can achieve this using graphical mapping also.

Former Member
0 Kudos

Hi Vijender,

You said that:

Employee Subgroup (P0001-PERSK) = 0F(Consultant)


But in your if condition:


persk[i].equals("OF")


Maybe try persk[i].equals("0F").


Regards,

Raye

vijender_p
Active Participant
0 Kudos

Sorry Raye !!!

its by mistake i have typed "OF" but it is "0F"

regards

vijender

Former Member
0 Kudos

Hi Vijender,

Why do you have to use FOR? Can you explain?

Regards,

Raye