cancel
Showing results for 
Search instead for 
Did you mean: 

Checking queue for content

Former Member
0 Kudos

Hi all,

I have a question concerning the mapping tool of PI. I want to know, if a queue has a real entry. When I use the function "exists", I got a "true" even when the queue has supresser. But I'd like to get a true only when the queue has a real entry (String). Could anybody help me here?

Thank You.

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Lukas

An alternative would be to handle the suppress values in the queue in a UDF.

You can create the following UDF of type "All Values of a Context"


public void customExists(String[] input, ResultList result, Container container) throws StreamTransformationException{

boolean found = false;

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

  if (!input[i].equals(ResultList.SUPPRESS)) {

    found = true;

    break;

  }

}

result.addValue(found);

}

With this, you can get the results as shown below:-

 

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,

Thanks for your response. That's what I'd like to have. I tried your code, but it seems not to work. I've added the cast for Boolean to String. Otherway, I will receive an error.

My coding is:

public void customer_exists(String[] a,ResultList result,Container container){

boolean found = false; 
for (int i = 0; i < a.length; i++ )

if (!a[i].equals(ResultList.SUPPRESS)) { 
found = true; 
break; 
  } 

String s = new Boolean(found).toString();

result.addValue(s); 
}

The result is:

Any ideas what I'm doing wrong?

Thank you.

Former Member
0 Kudos

Additional information to my posting:

The error message I got when I don't add the code

String s = new Boolean(found).toString();

is:

ResultList cannot be applied to (boolean)
result.addValue(found);

engswee
Active Contributor
0 Kudos

Hi Lukas

From your screenshot, I think you are using PI 7.0 or 7.1. I'm not sure if it behaves differently from PI 7.11 which I'm running on.

Instead of casting, you can also just declare the found variable as a String. Refer to the changes in red below.


String found = "false";

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

  if (!input[i].equals(ResultList.SUPPRESS)) {

    found = "true";

    break;

  }

}

result.addValue(found);

You mentioned that you received an error - can you give a screenshot of the error?

Also, can you give a screenshot of the logic and "display queue" entries of the function before the input of the UDF? I would like to the SUPPRESS and other queue values are generated.

Another thing, can you make sure that the execution type is "All Values of a Context". I can't remember how it looks like on the older XI/PI version.

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,

I'm using XI 3.0, not PI 7.0 or higher.

I changed the coding you descripetd and replaced the boolean with string. Then I don't get an error, but the result is the same. Only one entry with "true".

Please see the process before the UDF. The logic is:

If the D_98 is 'ST', I want to check the D_166_2 for entries. When the D_166_2 has an entry, I'd like to have a true as result. But in my example, the D_166_2 has no entries so the result should be false.

Thanks a lot for your assistance.

engswee
Active Contributor
0 Kudos

Looks like the addValue method of ResultList was changed from earlier releases:-

In the earlier version it can only accept String.

SAP Library - SAP Exchange Infrastructure

In the later version, it can accept any Object

Generated Documentation (Untitled)

Rgds

Eng Swee

engswee
Active Contributor
0 Kudos

Hi Lukas

I managed to dig up some old training material with XI3.0 screenshots. Can you please ensure that the whole queue IS NOT cached - uncheck the box shown below.

If that does not work, can you double-click the IF function, and check the box to keep the suppress values.

Rgds

Eng Swee

abranjan
Active Participant
0 Kudos

Hi Lukas,

If you condition involves D_166_2 to be checked as well, then you can try once by putting an 'AND' condition with the 'ST' check you are doing. Something like,

IF(d_98='ST' AND  D_166_2=> exists)

THEN pass D_166_2 to your UDF.


(For checking  D_166_2 existence, you can also use another compare function to see if it is empty or not, or if its length=0 or not - whatever way you feel convinced.)



Regards,

Abhishek

Former Member
0 Kudos

Hi Eng Swee,

I tested your proposal but same problem. I think that the codes

!a[i].equals(ResultList.SUPPRESS) or a[i] != "SUPPRESS"

dont't work correctly in XI 3.0. When I replace "SUPPRESS" by another string, it's working.

I suppose that the string of the blue suppress isn't "SUPPRESS" in XI 3.0.

engswee
Active Contributor
0 Kudos

Hi Lukas

Blue SUPPRESS is an actual suppress, with value ResultList.SUPPRESS.

The lines in dark grey are NOT suppress values - anything in dark grey are Context Changes - the value shown in "Display Queue" should be ignored. The actual value is ResultList.CC

Also, to compare Strings in Java, you need to use the equals method of the string - you cannot use = or !=.

Have you tried following my code above (using String for variable found) without any additional changes, AND making sure the Queue is not cached. And also the "Keep suppressed" checked?

If this still does not work for you, I suggest you go for Abhishek's suggestion. You don't need any UDF for that.

It would look something like below.

Rgds

Eng Swee

Former Member
0 Kudos

Yes I tried your code and replaced boolean with string. But finally, the suggestion of  Abhishek led to the wished result. Anyway, thanks a lot for your help.

Answers (3)

Answers (3)

vinaymittal
Contributor
0 Kudos

Use Remove Context and then check the exists.....

Harish
Active Contributor
0 Kudos

Hi Lukas,


Blue suppress will also true for exist function. Blue suppress has the value ResultList.SUPPRESS.


please refer the below blog


https://scn.sap.com/people/stefan.grube/blog/2006/01/09/the-use-of-suppress-in-the-xi-30-graphical-m...


the below discussion is also useful


http://scn.sap.com/thread/1903601


regards,

Harish

Muniyappan
Active Contributor
0 Kudos

Did you try remove context after exists function?