-
Book Overview & Buying
-
Table Of Contents
SAP ABAP Advanced Cookbook
By :
In this recipe, we will write a simple program that will function as an if statement. A simple find regex statement will be used.
We will first write an if statement that will check if the value of a parameter variable field1 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.

For replacing the if statement with find regex statement, proceed as follows:
Instead of the if statement, we will write a find regex statement along with the regex '[ABC|CDE|DEF]'.
After the statement, the sy-subrc is checked, and the appropriate messages are written.

We have used an OR (|) operator within the find statement. A match is found if the value of the three-character field1 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.
Change the font size
Change margin width
Change background colour