on 12-06-2006 11:53 AM
I am attempting to try a simple UDF
if (String a == String b || String a == String c)
return "yes";
however I get the following error...
Source code has syntax error:
/usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map03a9a9e0852011dbaae9000d60de069c/source/com/sap/xi/tf/_MM_Source_Target_.java:39: ')' expected
if (String a == String b || String a == String c)
^
1 error
Now clearly I am missing ')' somewhere but I dont understand where...
I am trying to do a simple if String 1 is equal to String B or String a is equalt to String c then result is yes.
Can some one let me know where Im going wrong
Thanks Sergio you are a genious
ok is there like a dictionary where I can find all of these values?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi alex,
thanks.......
Have a look at this
http://help.sap.com/saphelp_erp2005vp/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
Happy your problem is solved,
Regards,
Sergio
Alex,
I think you could also need java api (list of standard objects and methods for java developments) : http://java.sun.com/j2se/1.4.2/docs/api/
Have a look at object String and it's methods for example.
Regards,
Sergio
PS: do not forget to mark the problem as solved
Hi
<i>2. How do I return one value if condition is met but not map the target field at all if condition is not met. (it is ok to say no or blank but sometimes you just don't want a target field populated at all if conditions are not met)</i>
For this you can use bult in IfWithoutElse function, so you no need to put else case
Regards,
Sai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok it seems to work now... Problem with source XML...
But last questions....
1. Why use methods as oppose to operators? What if I need to say is a>b or a>=b how would I do that.... is there a methods dictionary?
2. How do I return one value if condition is met but not map the target field at all if condition is not met. (it is ok to say no or blank but sometimes you just don't want a target field populated at all if conditions are not met)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alex,
See the signature of the UDF.
It has to necessaily retun something.
May be if false
return"";
Empty String.
Regards,
Sudharshan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok adding the else seemed to work yet my target field didn't get mapped with yes or no?
Why is this?
I want it to map yes if conditoions are met and not map at all if conditions are not met?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
if ( a.equals(b) || a.equals(c))
return "yes";
else
return "no";
or
if ( a.equals(b) || a.equals(c))
return "yes";
return "no";
Both works fine
Regards,
Sai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
there is no else branch....
aahhh should I add an else branch anyway so to complete the scenario?
How could I return "Do not Map"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just tried your suggestion
if ( a.equals(b) || a.equals(c))
return "yes";
and it still says missing return statement?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also what if I wanted to say not equal to or greater than etc..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
12:02:11 Start of test
Source code has syntax error:
/usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map9c1db850852111dba2d2000d60de069c/source/com/sap/xi/tf/_MM_Source_Target_.java:42: missing return statement
}
^
1 error
12:02:15 End of test
Ok I got a new error.... this was before I read your above posts but I was wandering for my information if someone could tell me where I went wrong....
Why there is the return statement missing?
Also why should I not use operators.... I am new to java so just trying to understand... So why methods and not operators?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alex,
Hope a,b,c or inputs to the UDF..
By default a,b,c are names of parameter to the UDF.
use different names for local variables other than a,b,c etc
Regards,
Sudharshan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To compare two strings you should use equals method present inside String class.You should not use equals operator.
For example a.equals(b).
The equals method will return a true if both strings are equal.
Regards,
Sudheer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
String a;
String b;
String c;
if ( a.equals(b) || a.equals(c))
return "yes";
Regards,
Sergio
PS: a,b,c must be inputs of your UDF
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.