Entering content frameCombining Several Logical Expressions Locate the document in its SAP Library structure

You can combine several logical expressions together in one single expression by using the logical link operators AND and OR:

To negate the result of a logical expression, you can precede it with the NOT operator.

NOT takes priority over AND, and AND takes priority over OR. However, you can use any combination of parentheses to specify the processing sequence. As in mathematical expressions, ABAP interprets each parenthesis as a separate word. You must therefore leave at least one space before and after each one.

ABAP processes logical expressions from left to right. If it recognizes one of the component expressions as true or false, it does not perform the remaining comparisons or checks in this component. This means that you can improve performance by organizing logical expressions in such a way that you place comparisons which are often false at the beginning of an AND chain and expensive comparisons, such as searches for character strings, at the end.

Example

DATA: F TYPE F VALUE '100.00',
N(3) TYPE N VALUE '123',
C(3) TYPE C VALUE '456'.

WRITE 'The following logical expression is true:'.

IF ( C LT N ) AND ( N GT F ).
  WRITE: / '(',C,'lt',N,') AND (',N,'gt',F,')'.
ELSE.
  WRITE: / '(',C,'ge',N,') OR (',N,'le',F,')'.
ENDIF.

The output is:

The following logical expression is true:

( 456 ge 123 ) OR ( 123 le  1.000000000000000E+02 )

The logical expression in the IF statement is true, and the inverted expression is displayed.

 

 

Leaving content frame