cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding UDF JAVA code not working

Former Member
0 Kudos

Hi

I have written a udf cod for checking the condition i have tested the code in eclipse it is working fine but when i put the same code and test in pi

it not giving expected result

It is not evaluation the below condition in pi ( if (a.equals("F") && (b  != ("03"))))

String a = "F";

                    String b = "4";

                    String c= "";

                    System.out.println(a);

                    System.out.println(b);

 

                              if (a.equals("F") && (b  != ("03")))

                              {

                              c="test";

                              System.out.println(c);

                              }

                              else if(a.equals("F") && (b.equals("03")))

                              {System.out.println("PMI");}

 

 

                              else if (a.equals("E"))

                              {

                              System.out.println("FAB");

                              }

                              else if (a.equals("X"))

                              {

                                        System.out.println("MIX");

                              }

 

 

 

                              else

                                                  {

                                        System.out.println("NA");

                                                  }

          }}

Any suggestions

Thanks

Sankar

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi Sankar,

Simply replace each occurrence of System.out.println("SOMETHING") with result.addValue("SOMETHING") and it should work as expected.

Hope this helps,
Greg

Answers (2)

Answers (2)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Clarifying your questions.

System.out.println is used to write the output on the console ie. input output device. So you use in the eclipse to show the values during runtime. Similary in UDF you can write the output as log traces as mentioned on the above reply.

If you want to provide the output of the UDF to the target, you need to add to the ResultList object. In UDF we reference the ResultList class with result instance variable.

result.addValue("values that needs to be added");

Former Member
0 Kudos

System.out.println wil not work in UDF's.

try the below code which will add the message in the log:

container.getTrace().addInfo("your message");