Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for Byte String Processing →  bit_exp - Bit Expressions 

bit_exp - Calculation Length

A bit expression is assigned a calculation length in which the operation is executed.

The calculation length is the length of the longest bit expression operand involved. Unlike in the calculation type of an arithmetic expression, the type of the result is not included.

Before the entire expression is evaluated, all operands in question are converted to the length of the longest operand based on the rules for the source field type x and xstring. This means that shorter operands are padded with hexadecimal 0 on the right.

The result in the calculation length is handled as follows:

  • If used in the statement COMPUTE, the final result of the entire expression is converted to the length of the data object result based on the rules for source field type x and xstring. In assignments to an inline declaration DATA(var) the result of type xstring is located in the calculation length.
  • If used in relational expressions, the result is used as an operand in the length resulting from the calculation.
  • If used as an actual parameter for input parameters of methods, the final result of the entire expression is converted to the length of the formal parameter based on the rules for source field type x and xstring. If the formal parameter is typed generically, it is set to the type x in the length determined by the operands.

Other versions: 7.31 | 7.40 | 7.54


Example

The result of the following bit expression is hexadecimal 11111010, with a length of 4 bytes.

DATA hex1 TYPE xstring VALUE '10101010'. 
DATA hex2 TYPE xstring VALUE '0101'. 
cl_demo_output=>display( 
  |{ hex1 bit-or hex2 }\n{ 
     xstrlen( conv xstring( hex1 bit-or hex2 ) ) }| ).