on 01-12-2015 11:47 AM
Hi!
I want to compare a string with multiple values. Will .matches work in SAP PI? Or do I have to use equals?
if(Type.trim().matches("Z001|Z002|Z003|Z004|Z005|Z006"))
{
do something
}
or .equals
if(Type.trim().equals("Z001") || Type.trim().equals("Z002")) // etc
{
do something
}
hi Stefan,
PI(7.31) supports both the ways you have mentioned.
thanks and regards,
Praveen T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
The matches method is the quicker way to compare strings that i know (http://stackoverflow.com/questions/10205437/compare-one-string-with-multiple-values-in-one-expressio...)
However, in PI world is better to use the standard functions, because you can have SAP assistance if something fails and you can avoid problems in future upgrades.
In your case , you can use the Constant, equalS, Or and If-then-else functions:
Hope this helps
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
I did not try the matches but second one will definitely work.
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.