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 typex
andxstring
. In assignments to an inline declarationDATA(var)
the result of typexstring
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 argument of built-in functions or of constructor 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
andxstring
. If the formal parameter is typed generically, it is set to the typex
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 ) ) }| ).