log_exp - Comparison Operators for All Data Types

The following table lists the comparison operators for comparisons between operands of various data types.

Operator Description
=, EQ Equal: True, if the content of operand1 matches the content of operand2.
<>, NE Not Equal: True, if the content of operand1 does not match the content of operand2.
<, LT Lower Than: True, if the content of operand1 is smaller than the content of operand2.
>, GT Greater Than: True, if the content of operand1 is greater than the content of operand2.
<=, LE Lower Equal: True, if the content of operand1 is lower than or equal to the content of operand2.
>=, GE Greater Equal: True, if the content of operand1 is greater than or equal to the content of operand2.

The way in which the contents are compared depends on the data types of the operands (see below).

Notes

Comparing Compatible Elementary Types

If operand1 and operand2 have elementary data types and are compatible, their contents are compared by the following rules and without prior conversion:

The following individual behavior results from the rule for character-type types:

Comparing Incompatible Elementary Types

If operand1 and operand2 have elementary data types and are not compatible, their contents are converted and compared according to the following rules:

Operands of the same type with different lengths

Operands of different elementary types

If the operands have different data types, conversions take place according to the conversion tables and the following hierarchy:

  1. If one of the operands has a numeric data type (i, f, p), the other operand is converted to the relevant numeric data type with the largest value area; the value area of the data type f is greater than that of p, which in turn is greater than that of i.

  2. If one of the operands has the data type d or t and the other operand has a numeric data type (i, f, p), the content of the date or time field is converted to the numeric data type.

  3. If one of the operands has the data type d or t and the other operand has a character-type data type other than d or t (c, n, string), the content of the data or time field is also treated as character-type. If one of the operands has the data type d and the other has the data type t, an exception than cannot be handled occurs.

  4. If one of the operands has the data type n and the other operand has the data type c, string, x, or xstring, the content of both data types is converted to the data type p.

  5. If one of the operands has a data type of fixed length (c or x) and the other operand has a data type of variable length (string or xstring), the operand of fixed length is converted to the corresponding data type of variable length (c to string, x to xstring).

  6. If one of the operands has a byte-type type (x, xstring) and the other operand has a character-type type (c, string), the content of the operand with the byte-type type is converted to the corresponding character-type data type (x to c, xstring to string).

Comparing Reference Variables

Data references can be compared with data references and object can be compared with object references, but data references cannot be compared with object references. Two references are equal if they point to the same object. A size comparison is defined internally and always returns matching results in matching situations.

Note

In the case of data references, it is not sufficient for equality if the operands contain the same references; the data type of the referenced objects must be compatible. For example, if two reference variables, of which one points to a structure and the other to the first component of this structure, contain the same memory address, they are still not equal since the data type of the operands is incompatible. Reference variables filled using GET REFERENCE can be unequal, even if they point to the same data object, if GET REFERENCE is executed for a field symbol to which the data object was assigned using casting.

Comparing Structures

Structures can be compared with structures and elementary fields:

Comparing Internal Tables

Internal tables can be compared with other internal tables if their row types are comparable. Internal tables are compared according to the following hierarchy:

  1. The internal table that has more rows than the other internal table is larger.

  2. Internal tables with the same number rows are compared row by row. If an internal table contains nested internal tables, they are compared recursively. In the case of equal internal tables, the content matches row for row. With unequal internal tables, the first unequal pair of rows defines the result of the comparison.

Note

When specifying an internal table with header line as operand of a logical expression, in almost all operand positions the header line is addressed instead of the table body. To address the table body of a table with header line, you must append [] to the name.