A logical expression consists of comparisons (see expressions 1 to 4 below) and/or selection criteria
checks (expression 5) using the operators
AND, OR and
NOT
, as well as the parentheses "
(" and ")".
The individual operators, parentheses, values and fields must be separated by blanks:
NOT takes priority over AND,
while AND in turn takes priority over OR:
NOT f1 = f2 OR f3 = f4 AND f5 = f6
thus corresponds to
( NOT ( f1 = f2 ) ) OR ( f3 = f4 AND f5 = f6 )
The selection criteria comparisons or checks are processed from left to right. If evaluation of a comparison
or check proves part of an expression to be true or false, the remaining comparisons or checks in the expression are not performed.
All data objects that can be converted among each other can be used as operands for logical expressions.
Each operand can still be replaced by calling a predefined function (see
COMPUTE) or functional method. Functional methods
are methods in
ABAP Objects that have any number of IMPORTING parameters and one RETURNING parameter.
Depending on the number of IMPORTING parameters of the method, you can use the following notation:
The actual parameters are transferred to the IMPORTING
parameters of the method in the same way as for the statement CALL METHOD.
Performance:
The time taken to evaluate an expression often depends on how
it is structured. For example, you should place comparisons that are usually false at the beginning
of an AND chain and leave expensive comparisons like string searches until the end.
The following expressions are permitted:
1. Comparison expressions of the form f1 op f2
- Operators op
for all data types
(e.g. =, <,
>=)
- Operators
op
for character strings
(e.g. CO, CP,
CS)
- Operators
op
for byte sequences
(e.g. BYTE-CO, BYTE-CS)
- Operators op
for bit masks (O, Z,
M
)
2. Test for range membership
- f1
[NOT] BETWEEN f2 AND f3
3. Comparison with the initial value
- f IS INITIAL
4. Check whether a field symbol is assigned -
<fs> IS [NOT] ASSIGNED
5. Check whether
a reference is valid
- f IS
[NOT] BOUND
6. Check whether an actual parameter exists
- f IS [NOT] REQUESTED
7. Check whether an actual parameter is passed
- f IS [NOT] SUPPLIED
8. Comparison with a selection criterion
- f [NOT] IN sel
Using Fields with Dynamic Offset/Length Specification
If fields with dynamic offset/length
specifications are used in logical expressions, the area to be used is already calculated before the
logical expression.
This is relevant when the offset/length access results in a runtime error because,
for example, the specified offset is too large.
A runtime error also occurs when the associated logical expression is not interpreted at all.
Catchable Exceptions
CX_SY_CONVERSION_NO_NUMBER
Non-Catchable Exceptions
Logical Expressions