cancel
Showing results for 
Search instead for 
Did you mean: 

User Defined Function

Former Member
0 Kudos

Hi all,

I need to create a message mapping where two output messages are involved. I need to map the input to one of the output messages based on the value of one of the parameters. How to create a user defind functionfor the same.

Input structure: name , age

Output 1 : name, age

Output 2 : name, age, status

Here status has to be "Elgible" if age is above 18 else "not eligible".

Can any one please provide me with the details like what kind of UDF it should be, Simple or Advanced ? How many input parameters? and the jave code to be written in UDF? also how to map this to output ?

Help will be appriciated.

Thanks and best regards,

Kulwant

Accepted Solutions (1)

Accepted Solutions (1)

prateek
Active Contributor
0 Kudos

There is no need for UDF. U can directly use standard function "If"

and map the constants to it.

Regards,

Prateek

Former Member
0 Kudos

Hi Prateek,

Thanks for the information. Can you please write the steps here. I am new to message mapping. This will really help me.

Thanks and best regards,

Kulwant

justin_santhanam
Active Contributor
0 Kudos

Kulwant,

If the target is two messages, then follow the logic.

For Message 1

Name ---> Name

Age -


> Age

For Message 2

Name -


>Name

Age------>Age

Age & Constant(18) -


>greater------>IF Then Else -


>Eligibility

Then -


> Constant(Eligible)

Else -


>Constant(Not Eligible)

raj.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Kulwant,

put this code in your udf for geting the status depending upon the age.

Step 1: Create a simple udf named getStatus with two arguments : name and age

Step 2: After creating paste the below code in the udf editor.

public String getStatus(String name,String age,Container container){

if(Integer.parseInt(age)>18)

return "Eligible";

else

return "Not Eligible";

}

Step 3: Save & Close the udf editor and test your mapping.

Please reward points if helpful.

Regards,

Sankar

Former Member
0 Kudos

Hi

u can use the foloowin udf.

the udf is having three inputs.

a----->age

b----->name

c----->status

for(int i=0;i<a.lrength;i++)

{

if(a<i>.equals("18"))

{

result.addValue(a);

result.addValue(b);

}

else

{

result.addValue(a);

result.addValue(b);

result.addVAlue(c);

}

}

if u still face the problem please reply me back.

Thanks

Rinku

justin_santhanam
Active Contributor
0 Kudos

Kulwant,

You have one source message and two target messages is it?

raj.

Former Member
0 Kudos

hello raj,

yes. But only one of them needs to be mapped based on the value of age.

Thanks and best regards,

Kulwant

Former Member
0 Kudos

Hi,

for this you can use standard Boolean function,i.e ifwithoutelse

i think...

correct me if am wrong........

note:rewards points if solution found helpfull....