Entering content frame

Comparisons Locate the document in its SAP Library structure

In general, the rule applies that operands that can be assigned to one another with the MOVE statement can also be compared. An exception is object references, which can be compared but not always assigned.

Comparison of flat structures

Structures can also be compared if they are not compatible. As in the MOVE statement, the fragment views must be the same for the length of the shorter structure. If the structures have different lengths, the shorter structure is filled until it has the length of the other structure. As in the assignment, all character-type components are filled with spaces and all other components with initial values of the right type. The structures are compared fragment by fragment as defined by the fragment view.

Comparison of single fields and structures

The following rules are valid when single fields are compared with structures:

  1. If a structure is of character-type only, it is treated like a C field in the comparison.
  2. If the single field is of character-type, but the structure is only partly of character-type, the comparison is only possible if the first fragment of character-type in the structure is longer than the single field. The single field is extended to the structure length at runtime and filled with initial values for the comparison. The comparison is the same as for structured fields, where the fields are filled as in the MOVE statement.


c0(10)   TYPE C.

BEGIN OF struc,
  c1(15) TYPE C,
  i      TYPE I,
  c2(5)  TYPE C,
  n(7)   TYPE N,
END OF struc.

... c0 logexp struc ...

In this example, c0 is extended to the length of struc in storage. All areas > 10 are filled with initial values of the correct type for components that are not character-type and filled with space for other components.

Comparison of deep structures

As previously, mainly type compatibility of the operands is needed for comparing deep structures. The compatibility test for comparability was generalized so that structure components with references to classes or interfaces can be compared with one another, whatever the class hierarchy and implementation relation, as for single fields. Only comparability of table types is required for table components.

Comparison of internal tables

Tables can be compared if their row types can be compared. The restrictions described above therefore also affect table comparisons.

Note Use the categories used in the Dictionary when using these types with Structure Enhancements.



Leaving content frame