cancel
Showing results for 
Search instead for 
Did you mean: 

User Defined Function issue

Former Member
0 Kudos

Hi, I have created a user defined function in message mapping and it works fine as it is but now the customer wants to changes something and I don't know how to implement it.

My current code which works:

String INVTnegCT="1";

String INVTposCT="2";

if (a.equals("INVTnegCT")

{

return INVTnegCT;

}

else {

return "INVTposCT";

}

But they want me to change neg/pos to -/+ for example INVTposCT to INVTCT but it seems that I can't use -/ in the function. is there a way to do it?

thanks for response!

Accepted Solutions (1)

Accepted Solutions (1)

former_member181985
Active Contributor
0 Kudos

No we cannot. It's a violation of language constructs.

But I am wondering what is the necessity of defining variable like that as you are returning their value not the variable name itself.

I think may be they are asking you for this

String INVTnegCT="INVT-CT";//modified here
String INVTposCT="INVT+CT";//modified here

if (a.equals("INVTnegCT")

{
return INVTnegCT;
}

else {
return "INVTposCT";
}

Edited by: Praveen Gujjeti on Mar 24, 2009 5:39 PM

Former Member
0 Kudos

The thing is that their input is either INVT-CT or INVT+CT and that will give the output 1 or 2.

so it should be something like this: (even if this does not work)

String INVT-CT="1";

String INVT+CT="2";

former_member181985
Active Contributor
0 Kudos

then this code will work.

String INVTnegCT="1";
String INVTposCT="2";

if (a.equals("INVT-CT")

{
return INVTnegCT;
}

else {
return INVTposCT;
}

input will be from source structure field and that is variable a in UDF. It can have values INVT-CT (or) INVT+CT.

Edited by: Praveen Gujjeti on Mar 24, 2009 5:51 PM

Former Member
0 Kudos

Hi,

use graphical mapping for this case..........take your input node, take a constant INVT-CT and use Text standard function equalS and then take this output to Boolean if function........then in then have a constant 1 and in else have 2.........

or if you want to use UDF only then:

String INVTnegCT="1";

String INVTposCT="2";

if (a.equals("INVT-CT")

{

return INVTnegCT;

}

else {

return "INVTposCT";

}

Regards,

Rajeev Gupta

Former Member
0 Kudos

Thank you! that solved my problem I know i Could do graphical mapping but there were too many strings to handle..1 and 2 where just an example. there were between 15-20 different strings so it was easeir by user defined function.

thanks for all the answers guys!

Answers (2)

Answers (2)

former_member181955
Contributor
0 Kudos

Hi

Do you need to pass either of INVT-CT or INVT+CT as return value.

If it is so, please check the below code.

String strneg ="INVT-CT";

String strpos ="INVT+CT";

if(a.equals("INVTnegCT")

{

return strneg;

}

else {

return strpos;

}

Thanks

Prasad Nemalikanti

Former Member
0 Kudos

do onething

declare and assign string pos = "+" and neg ="-"

then return these strings based on the logic you write instead of earlier things

otherwise concat strings with needed fied andsend the response

if not clear for you post the exact req in detail

Rajesh