Ansicht
Dokumentation

ABAPGET_BIT - GET BIT

ABAPGET_BIT - GET BIT

General Data in Customer Master   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

GET BIT

Short Reference



GET BIT bitpos OF byte_string INTO val.

Effect

This statement reads the bit at the bit position bitpos of the data object byte_string and assigns its value to the target field val. val can be specified as follows:

  • An existing variable that expects the data type i.
  • Expressions with the CAST and NEW operators and table expressions.

The data object byte_string must be byte-like. Bit, constructor and table expressions can be used. bitpos is a numeric expression position of operand type i. The value of bitpos must be greater than 0, otherwise uncatchable exceptions are raised. The bit positions in byte_string are counted from left to right, starting with the most significant bit (MSB) of the data object. If the value of bitpos is greater than the number of bits in byte_string, no bit is read and sy-subrc is set to 4.

System Fields

sy-subrc Meaning
0 The value of the bit at position bitpos of byte_string was placed in the result field val.
4 The value of bitpos is greater than the number of bits in byte_string and no bit was read.

Notes

  • If byte_string has the deep type xstring, a bit is read from the referenced byte string, not from the reference.
  • The reading of single bits is especially intended for evaluating the results of bit expressions.

The hexadecimal value "1B" is assigned to the data object hex and its bits are read from front to back. The output is "00011011", which corresponds to the binary representation of decimal 27 or hexadecimal "1B".

The hexadecimal value "1B" is assigned to the data object hex and its bits are read from front to back. The output is "00011011", which corresponds to the binary representation of decimal 27 or hexadecimal "1B".

Example

Hexadecimal values are assigned to data objects and included in an internal table which is looped across. During the loop, the bits are read from front to back. Finally, the result is added to the internal table which shows the hexadecimal and binary values. The GET BIT statement demonstrates a table expression following OF.



Exceptions

Non-Catchable Exceptions

  • Cause: n is smaller than or equal to 0.
    Runtime Error: BIT_OFFSET_NOT_POSITIVE






Addresses (Business Address Services)   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 5260 Date: 20240419 Time: 110037     sap01-206 ( 69 ms )