sapdev logo background
sapdev logo sapdev logo
Comments

SAP LOGEXP CHARACTER documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

rel_exp - Comparing Character-Like Data Types
The following tables show the comparison types
for comparisons between character-like data types and other data types. If the type of an operand is not the same as the comparison type, then it is converted to this type. If no comparison type is specified for a combination, then no comparison is possible.

Comparisons with Numeric Data Types
- string , c , n d , t
decfloat34 decfloat34 decfloat34
decfloat16 decfloat34 decfloat34
f f f
p p p
int8 int8 int8
i i i
s i i
b i i

Comparisons with Character-Like Data Types
- string c n d t
string string string p string
string
c string c p c c
n p p n n n
d string c n d -
t string c n - t
Length Adjustments
  • Operands with a different length of data type string never match. If the contents of the operands match for the length of the shorter operand, the shorter operand is smaller than the longer one. Otherwise the surplus places in the longer field are truncated on the right, and then the content is compared.

  • For comparisons between two operands of data type c , the shorter field is converted to the longer field, with blanks used as padding on the right.

  • For comparisons between two operands of data type n , the shorter field is converted to the longer field, with the character "0" used as padding on the left.

  • For comparisons between data types c , n , or string on the one hand and d on the other, the longer field is truncated on the right to the length of the shorter field, as long as only blanks are truncated.

  • For comparisons between data types c or n on the one hand and t on the other, the longer field is truncated on the right to the length of the shorter field, as long as only blanks are truncated.

  • Lengths are not adjusted for comparisons between the data type

  • string and the data type t .

    Note
    For comparisons between text fields of the type c and text strings of the type string , note that trailing blanks are ignored by conversions from c to string . This can have unexpected results. The conversion operator
    CONV can be used here to force other comparison types (see the example after the link).

    Example
    In the following comparison, the comparison type is c and the comparison takes places in the current code page , in accordance with the binary representation. In most code page s, "a" is greater than "Z". See also the example for
    CONVERT TEXT .
    IF 'a' > 'Z'.
    cl_demo_output=>display_text( `'a' > 'Z'` ).
    ELSE.
    cl_demo_output=>display_text( `'a' <(><<)> 'Z'` ).
    ENDIF.

    Example
    The following comparison is false, which is probably unexpected. The value returned by boolc has the type string and includes a blank, whereas the constant abap_false
    has the type c . For the comparison, the value of
    abap_false is converted to an empty string, since the blank it contains is ignored.
    IF boolc( 1 = 2 ) = abap_false.
    cl_demo_output=>display_text( 'yes' ).
    ELSE.
    cl_demo_output=>display_text( 'no' ).
    ENDIF.

    Comparisons with Byte-Like Data Types
    - string c n d , t
    xstring string string p i
    x string c p i
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    LOGEXP_BYTES
    LOGEXP_COMP




    comments powered by Disqus