sapdev logo background
sapdev logo sapdev logo
Comments

SAP UNICODE COMPARISON documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

Comparisons

Overview
1 Comparisons between flat structures
2 Comparisons between single fields and structures
3 Comparison of deep structures
4 Comparison of internal tables
In general, operands that can be assigned to one another with the MOVE statement can also be compared. Object references are an exception to this rule - they can be compared but not always assigned.




1 Comparisons between flat structures
Structures can also be compared, even if they are not compatible. As in the MOVE statement, the Unicode 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. All character type components are filled with spaces and all other components with initial values of the right type - similar to assignments. The structures are compared fragment by fragment as defined by the Unicode fragment view.



2 Comparisons between single fields and flat structures
The following rules apply when single fields are compared with structures:
  • If a structure is of character-type only, it is treated like a C field in the comparison.

  • If the single field is of type C, but the structure is only partly character-type, the comparison is only possible if the first fragment in the structure is character-type and is the same length as the single field or longer. For the comparison, the single field is extended to the structure length at runtime and implicitly handled like a structure. The character-type parts of the extension are filled with blank characters, all other components are filled with the type-related initial value. The comparison then takes place as it does between two structures

  • The comparison cannot be made, where the single field is not of type C and the structure is not completely character-type.


  • Example
    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.
    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 spaces for other components.



    3 Comparisons between deep structures
    As before, you can only compare two deep structures if they have compatible types. 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.



    4 Comparisons between internal tables
    Tables can be compared if their row types are comparable. The restrictions described above therefore also affect table comparisons.
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    UNICODE_COMMENTS
    UNICODE_CONVERSIONS




    comments powered by Disqus