ABAP provides a rich set of operators to manipulate variables. All ABAP operators are classified into four categories −
Character String Operators
DATA: A TYPE I VALUE 150,
B TYPE I VALUE 50,
Result TYPE I.
Result = A / B.
WRITE / Result.
= or EQ
<> or NE
> or GT
< or LT
>= or GE
Greater than or equals
<= or LE
Less than or equals
a1 BETWEEN a2 AND a3
CONTENTS NOT CHANGEDAND has been ASSIGNED ITS INITIAL VALUE
IS NOT INITIAL
NOTE - If the data type or length of the variables does not match then automatic conversion is performed. Automatic type adjustment is performed for either one or both of the values while comparing two values of different data types. The conversion type is decided by the data type and the preference order of the data type.
If one field is of type I, then the other is converted to type I.
If one field is of type P, then the other is converted to type P.
If one field is of type D, then the other is converted to type D. But C and N types are not converted and they are compared directly. Similar is the case with type T.
If one field is of type N and the other is of type C or X, both the fields are converted to type P.
If one field is of type C and the other is of type X, the X type is converted to type C.
DATA: A TYPE I VALUE 115,
B TYPE I VALUE 119.
IF A LT B.
WRITE: / 'A is less than B'.
A is less than B
DATA: A TYPE I.
IF A IS INITIAL.
WRITE: / 'A is assigned'.
A is assigned.
四、Character String Operators
Contains Only Checks whether A is solely composed of the characters in B
NOT Contains Only Checks whether A contains characters that are not in B
Contains Any Checks whether A contains at least one character of B
NOT Contains Any Checks whether A does not contain any character of B
Contains a String Checks whether A contains the character string B
NOT Contains a String Checks whether A does not contain the character string B
Contains a Pattern Checks whether A contains the pattern in B
NOT Contains a Pattern Checks whether A does not contain the pattern in B