Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Program Flow →  Expressions and Functions for Logical Expressions →  log_exp - Logical Expressions →  log_exp - Comparisons →  log_exp - Relational Operators 

log_exp - relational operators for byte-type data types

The following table shows the relational operators for comparisons between byte-like operands (single operands or bit expressions).

operator meaning
BYTE-CO Contains Only: True, if operand1 only contains bytes out of operand2.If operand2 is of type xstring and initial, thenthe logical expression is false, except if operand1 is also of type xstring and initial. Then the logical expression is always true. If the comparison is false,then sy-fdpos contains the offset of the first byte in operand1,which is not contained in operand2. If the comparison is true, then sy-fdpos contains the length of operand1.
BYTE-CN Contains Not Only: True, if a logical expession with BYTE-CO is false,if operand1 does not only contains bytes out of operand2.If the comparison is true, then sy-fdpos contains the Offset of the firstcharacter in operand1, which is not contained in operand2.If the comparison is false, then sy-fdpos contains the length of operand1.
BYTE-CA Contains Any: True, if operand1 contains at least one byte out of operand2. If operand1 or operand2 are ofthe type xstring and initial, only the logical expression is always false.If the comparison is true, then sy-fdpos contains the offset of the firstcharacter in operand1 which is also contained in operand2.If the comparison is false, then sy-fdpos contains the length of operand1.
BYTE-NA Contains Not Any: True, if a logical expression with BYTE-CA is false,if operand1 does not contain a byte out of operand2.If the comparison is false, then sy-fdpos contains the offset of the firstcharacter in operand1 which is contained in operand2.If the comparison is true, then sy-fdpos contains the length of operand1.
BYTE-CS Contains String: True, if the content of operand2 is contained in operand1. If operand1 is of type xstringand initial, then the logical expression is false, unless operand2 is alsoof type xstring and initial. Then, the logical expression is always true.If the comparison is true, then sy-fdpos contains the offset of operand2in operand1. If the comparison is false, then sy-fdpos contains the length of operand1.
BYTE-NS Contains No String: True, if a logical expression with BYTE-CS is false,if operand1 does not contain the content of operand2.If the comparison is false, then sy-fdpos contains the offset of operand2in operand1. If the comparison is true, then sy-fdpos contains the length of operand1.

Other versions: 7.31 | 7.40 | 7.54


Example

The logical expression in the IF statement is true, if the second half-byte is not filled at none of the bytes in hex1.

DATA: hex1 TYPE xstring,
      hex2 TYPE xstring.

hex1 = ...
hex2 = '000102030405060708090A0B0C0D0E0F'.

IF hex1 BYTE-CO hex2.
  ...
ENDIF.