on 08-26-2016 12:56 AM
Hello All,
I tried to write UDF as below but got lot of errors.
can you check and let me know.
Thanks
String output = "";
if (KOTABNR = "946"||"924")
{
output = VKORG+VTWEG+KUNNR+DATBI;
result.addValue(output);
}
else if (KOTABNR = "906" ||"917"||"924"||"903")
{
output = VKORG+VTWEG+KUNNR+MATNR+DATBI;
result.addValue(output);
}
else if (KOTABNR = "702")
{
output = MATNR+CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR = "928")
{
output = VKORG+VTWEG+KUNNR+DATBI;
result.addValue(output);
}
else if (KOTABNR = "703")
{
output = CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR = "946")
{
output = VTWEG+KUNNR+DATBI;
result.addValue(output);
}
else if (KOTABNR = "700")
{
output =VKORG+KUNNR+MATNR+CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR = "701")
{
output =VKORG+KUNNR+CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR = "928")
{
output =VKORG+VTWEG+KUNNR+DATBI;
result.addValue(output);
}
Hi Chinna,
The comparison format you have used is wrong. As you have written digit in "946", it
means it will work as a String and for this you should use equals() or == to compare value.
Pls try like this:
if (KOTABNR.equals("946") || KOTABNR.equals("924"))
It will work for sure.
Regards,
Gaurav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chinna Chinna,
Please provide the complete UDF along with function name and input arguments.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello all,
thanks for the inputs. now i am getting error
operator + cannot be applied to java.lang.String[],java.lang.String[]
output = VKORG+VTWEG+KUNNR+DATBI;
public void VARKEY(String[] VKORG,String[] VTWEG,String[] KUNNR,String[] MATNR,String[] DATBI,String[] CMPGN_ID,String[] KOTABNR,ResultList result,Container container){
string output = "";
if (KOTABNR.equals("946") || KOTABNR.equals("924"))
{
output = VKORG+VTWEG+KUNNR+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("906") || KOTABNR.equals("917") || KOTABNR.equals("924") || KOTABNR.equals("903"))
{
output = VKORG+VTWEG+KUNNR+MATNR+DATBI;
result.addValue(output);
}
else if (KOTABNR = "702")
{
output = MATNR+CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("928"))
{
output = VKORG+VTWEG+KUNNR+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("703"))
{
output = CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("946"))
{
output = VTWEG+KUNNR+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("700"))
{
output =VKORG+KUNNR+MATNR+CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("701"))
{
output =VKORG+KUNNR+CMPGN_ID+DATBI;
result.addValue(output);
}
else if (KOTABNR.equals("928"))
{
output =VKORG+VTWEG+KUNNR+DATBI;
result.addValue(output);
}
}
Hi Chinna,
what do you mean by plus(+) here. do you want to concatenate these values?
Plus(+) will not work for array of string[]. for that we need to use for() loop to concatenate these value.
Please provide the expected output with an example. i'll try to provide the code for that.
Regards,
Gaurav
Hi,
Let me give you a few hints to get you going:
1) Your comparison of values in incorrect. check the syntax online and there are plenty of materials on this.
2) Have you declared the fields that you are using in code as input parameters?
3) Have you declared the type of fields that you are using correctly?
4) Do consider what should be the outcome if none of the cases mentioned here are matched?
5) You can reduce the length of code by performing the concatenation directly within the result.addValue.
Can I suggest that you invest some time brushing up your skills on Java, as it can prove pretty useful. Here is a site I can recommend:
Happy learning.
Cheers,
Sanjeev.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
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.