cancel
Showing results for 
Search instead for 
Did you mean: 

UDF is not working properly in PI ( Message mapping )

0 Kudos

Hi Experts  ,

I am trying to split a string array of length 42 (which can vary in future if a new entry is added) . The code i used was checked in Java it works absolutely fine  however, the same in PI is throwing me a value like "Ljava.lang.String;@5b275936 " when i try to print in trace . It is not printing all the 42 value's . Please help me on where i have gone wrong. I am using PI 7.40 dual stack.

Code below is the code i have used in my message mapping.

try

{

String s3 = Arrays.toString(StrCC).replaceAll("\\[|\\]|\\s","");

String CC[] = s3.split(";");

getTrace().addInfo(" value if split cc is"+CC.length);

getTrace().addInfo(" value of split cc is"+CC);

  for(int i=0;i<CC.length;i++)

  {

getTrace().addInfo(" value if split cc is"+CC.length);

  for(int j=0;j<StrEntitycode.length;j++)

  {

StrEntitycode[j] = StrEntitycode[j].substring(0,3);

  if(CC[i].matches(StrEntitycode[j]))

    {

    result.addValue("TRUE");

        }else

                 {

                  result.addValue("FALSE");

             }

        }

   }

}

catch(Exception e)

{

e.printStackTrace();

}

Accepted Solutions (1)

Accepted Solutions (1)

Hi All,

Thanks for the suggestions. My issue was resolved . The reason for this error was while binding the parameter in Operation mapping. The value was given as 'value' once the quotes were removed they worked perfectly fine and my values are getting displayed.

Thanks ,

Sukanya Srinivasan.

Answers (4)

Answers (4)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

Can you give us a sample string?

Regards,

Mark

0 Kudos

Hi Mark ,

Strcc value  is 109,129,265,101A,461,475,013,022,023,024

the value of Strentitycode is being pulled from a file ,  the Strentitycode value should contain at least one of the Strcc value

p1024029
Participant
0 Kudos

Hi

Please ignore if i misunderstood ur problem.

try

{

String s3 = Arrays.toString(StrCC).replaceAll("\\[|\\]|\\s","");

String CC[] = s3.split(";");

getTrace().addInfo(" value if split cc is"+CC.length);

getTrace().addInfo(" value of split cc is"+CC); // This will not print the value

getTrace().addInfo(" value of split cc is"+Arrays.toString(CC));// This will print something like [a,b,c,d...]

  for(int i=0;i<CC.length;i++)

  {

getTrace().addInfo(" value if split cc is"+CC.length);

getTrace().addInfo(" value split cc is"+CC[i]);// Use this to print individual values

  for(int j=0;j<StrEntitycode.length;j++)

  {

StrEntitycode[j] = StrEntitycode[j].substring(0,3);// better use local variable here

  if(CC[i].matches(StrEntitycode[j]))

    {

    result.addValue("TRUE");// If you just need single value then you can break the execution

break;

        }else

                 {

                  result.addValue("FALSE");

             }

        }

   }

}

catch(Exception e)

{

e.printStackTrace();

}

NB

0 Kudos

Hi Naresh ,

Thanks for the suggestion , i got the values  on how it has to be printed.

former_member182412
Active Contributor
0 Kudos

Hi Sukanya,

You are printing the object directly. So you are getting object reference.


getTrace().addInfo(" value of split cc is"+CC);

Change like below.


getTrace(" value of split cc is" + Arrays.toString(CC));

Regards,

Praveen.

0 Kudos

Hi Praveen ,

I have already converted it to array on the top , My aim to print the value here is just to make sure all the values in my array are printed. Please let me know if still have to use the conversion again.

former_member182412
Active Contributor
0 Kudos

Hi Sukanya,

Then print String s3 is enough.

getTrace().addInfo(" value of split cc is"+ s3);


Regards,

Praveen.

0 Kudos

Hi Praveen ,

Yes i tried it now  , still the value is printed as 1 ( the first value is my string is 109) and the length is also printed as one  , but my main requirement here is to split the string . The value CC holds the split string .

former_member182412
Active Contributor
0 Kudos

Can you provide StrCC and StrEntitycode values and what is execution type of your UDF?? can you past the UDF signature also??

0 Kudos

Strcc value  is 109,129,265,101A,461,475,013,022,023,024

the value of Strentitycode is being pulled from a file ,  the Strentitycode value should contain at least one of the Strcc value

UDF type is all values of a queue .

former_member182412
Active Contributor
0 Kudos

Hi Sukanya,

You are splitting the string by using semi colon but your input string (109,129,265,101A,461,475,013,022,023,024) does not contain semi colon


String CC[] = s3.split(";");

So you can use comma instead of semi colon.


String CC[] = s3.split(",");

Regards,

Praveen.

0 Kudos

Hi Praveen ,

It was a typo , in my receiver determination , i have split the value with ";" . I have a doubt if it is with the type of my UDF that is creating trouble. Please let me know .

former_member186851
Active Contributor
0 Kudos

Hello Sukanya,

If you wish to split the string based on : like (test;123 = test and 123)

Check the below link

0 Kudos

Hi Sritharan ,

The value is for one string alone and it holds 42 value, so splitting like as provided in the link will be a tedious process.

former_member182412
Active Contributor
0 Kudos

Hi Sukanya,

I have done the same UDF on my side and it is working.

Regards,

Praveen.

0 Kudos

Hi Praveen,

This worked , but now my values are being printed in Message mapping  , but the same is not getting reflected in Moni , when i tried to check the trace .

when i checked my operation mapping , the test turned out to be successful  , but my result was not printed in the receiver message mapping part  , in the operation mapping. Just to add , my receiver is Standard receiver from SAP in the namespace http://sap.com/xi/XI/System ( Receivers). This has an extended receiver determination in the ID side to determine to which receiver the flow should go .

The receiver is getting determined in message mapping when i tested but not in operation mapping.

former_member186851
Active Contributor
0 Kudos

Hello Sukanya,

Guess your trying to split a single array,

And no need to go for queue/contexts.

Let us know if you wish to split the string based on ,(comma).

0 Kudos

Hi Sritharan,

I have to split the string based on ; because  i have given an Signature  value  in my message mapping . That value holds the single array. I have to compare the value one by one to print the result. Will it work if i use a "," ? as i have used extended receiver determination and the values of CC is being given there split by ";"

bhavesh_kantilal
Active Contributor
0 Kudos
  • getTrace().addInfo(" value of split cc is"+CC); --> This line will definitely return Ljava.lang.String;@5b275936


  • If you do a System.out.println(" value of split cc is"+CC); in your standalone java code -> the output will be similar.

Regards

Bhavesh

0 Kudos

Hi Kantilal ,

The code works fine in Eclipse , But the same is not working in PI message mapping . The reason i am printing the trace is to check if my array values are  split properly . This statement shows  that array value is not split. Please help me if i have gone wrong in the split statement.

bhavesh_kantilal
Active Contributor
0 Kudos

Hello Sukanya,

- System.out.println will not work in PI. What I meant was that the trace you are printing if done in your standalone Java Code will also return the same value.

Regards

Bhavesh