Usage of REGEX Statement instead of IF statement with multiple Conditions
Tips and Tricks:
Code a program with if statement that will check if the
value of a parameter variable field has the value equal to ABC, DEF, or CDE. In
case the value is equal to any of the three, the message Field Value is Valid
is displayed. We will then see the equivalent regex.
Instead of IF statement, write a find REGEX statement along
with the regex '[ABC|CDE|DEF]'.
We have used an OR (|) operator within the find statement. A
match is found if the value of the three-character field is equal to any of the
three values specified. In this case, sy-subrc is equal to zero, and the
success message is then displayed.
In case, you need to ignore the CASE, add IGNORING CASE in
the FIND REGEX statement.
No comments:
Post a Comment