GET BIT

Basic form 9

GET BIT n OF f INTO g.

Effect

The nth bit (from the left, beginning at 1) of field f is placed in the field g.
n must be positive and be convertible into type I. The value of n must not be longer than the length in bits of f.
f must have type X, and can be of any length up to the maximum permitted for type X.
You can use a XSTRING-type variable instead of a field. Note that n does not overwrite the current length of f; the system does not adjust the length in any way.

,,The Return Code is set as follows:

SY-SUBRC <> 0:
The value of n is greater than the length in bits of f. g takes the value 0 in this case.
SY-SUBRC = 0:
The bit has been placed in field g.

Example

DATA: F(2) TYPE X VALUE '8000',
      G    TYPE I.
GET BIT 1 OF F INTO G.
WRITE G.

Output:          1

Exceptions

Non-Catchable Exceptions

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Changes Relating to Unicode

Related

SET BIT, Bit operations

Additional help

Setting and Reading Bits