ABAP Keyword Documentation → ABAP - Reference → Program Flow Logic → Expressions and Functions for Conditions → log_exp - Logical Expressions → rel_exp - Predicates
rel_exp - Predicative Method Call
Other versions:
7.31 | 7.40 | 7.54
Syntax
... meth( ... ) ...
Effect
A predicative method call is a relational expression whose only operand is a functional method call meth( ... ). The result of the relational expression is true if the result of the functional method call is not initial and false if the result of the functional method call is initial. The result of the functional method call (the return value of the called function method) can have any data type. A check is made on the type-compliant initial value.
A predicative method call, like any relational expression, can be a full logical expression or part of a logical expression. This means it can be specified as a condition in control statements and other statements, as an argument in Boolean functions or conditional expressions, or in joins with Boolean operators.
Notes
- A predicative method call is a short form of the predicate expression:
... meth( ... ) IS NOT INITIAL ...
- Predicate methods
whose return value has the type
abap_bool
are particularly well suited as predicative method calls. Calling a predicate method in a predicative method call simulates the call of a method whose return value has the real Boolean data type not present in ABAP.
- As usual, the functional method call
meth( ... )
can be specified as a individual method or as a method chaining. If the first method called is an instance method, the functional method call can be introduced as usual using the instance operatorNEW
or the casting operatorCAST
.
- Alongside the dedicated predicate functions and an obsolete short form, predicative method calls are the only way of creating a relational expression using a single operand.
- For other expressions or data objects, the full predicate expression
IS INITIAL
or a comparison must be used to check the initial value and this is not normally recommended for many expressions.
Example
Exits the program if no SAP GUI is available. The called method check
from the class CL_DEMO_SAP_GUI is a
predicate method.
IF NOT cl_demo_sap_gui=>check( ).
LEAVE PROGRAM.
ENDIF.
Example