SET BIT

Basic form 18

SET BIT n OF f.

Extras:

1. ... TO g

Effect

The nth bit (from the left, starting at 1) of field f is set to 1.
n must be positive, and either have type I or be convertible into this type. The value of n must not exceed the length (in bits) of f.
f must have type X. It can be of any length up to the maximum permitted for data type X.
You can also use a variable of the type XSTRING instead of a field. Make sure that n does not exceed the current length of f; the length is not adjusted.

The Return Code is set as follows:

SY-SUBRC <> 0:
The value of n was greater than the length in bits of f.
SY-SUBRC = 0:
The bit was set.

Addition 1

... TO g

Effect

You can use the ... TO g addition to determine the value to which the bit should be set. g must have the value 1 or 0.

Example

DATA F(2) TYPE X.
SET BIT 1 OF F.
WRITE F.

Output: 8000

Exceptions

Non-Catchable Exceptions

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

See Unicode Changes

Related

GET BIT, Bit Operations

Additional help

Set and Read Bits