on 04-29-2014 3:40 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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.
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
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
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.
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
Use Remove Context and then check the exists.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lukas,
Blue suppress will also true for exist function. Blue suppress has the value ResultList.SUPPRESS.
please refer the below blog
the below discussion is also useful
http://scn.sap.com/thread/1903601
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you try remove context after exists function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.