* DEMO_DATA_BIT
TRY.
* zwei Bytes
DATA: lv_xa TYPE x LENGTH 1.
DATA: lv_xb TYPE x LENGTH 1.
* Bit 1 und 8 setzen
SET BIT 1 OF lv_xa.
SET BIT 8 OF lv_xb.
* xstring mit Bit == 1 an der 7. Stelle
DATA(lv_hex) = bit-set( 7 ).
cl_demo_output=>write_data( lv_xa ).
cl_demo_output=>write_data( lv_xb ).
cl_demo_output=>write_data( lv_hex ).
* Bit 1 lesen
DATA(lv_bit1) = 0.
GET BIT 1 OF lv_xa INTO lv_bit1.
cl_demo_output=>write_data( lv_bit1 ).
* Bit 8 lesen
DATA(lv_bit8) = 0.
GET BIT 8 OF lv_xb INTO lv_bit8.
cl_demo_output=>write_data( lv_bit8 ).
DATA: lv_and TYPE x LENGTH 1.
DATA: lv_or TYPE x LENGTH 1.
DATA: lv_xor TYPE x LENGTH 1.
DATA: lv_not TYPE x LENGTH 1.
* AND
lv_and = lv_xa BIT-AND lv_xb.
cl_demo_output=>write_data( lv_and ).
* OR
lv_or = lv_xa BIT-OR lv_xb.
cl_demo_output=>write_data( lv_or ).
* XOR
lv_xor = lv_xa BIT-XOR lv_xb BIT-XOR lv_hex.
cl_demo_output=>write_data( lv_xor ).
* NOT
lv_not = BIT-NOT lv_xb.
cl_demo_output=>write_data( lv_not ).
* Bitweises lesen
DATA(lv_bitstring_a) = ||.
DATA(lv_bitstring_b) = ||.
DATA(lv_bitstring_hex) = ||.
DATA(lv_bitstring_and) = ||.
DATA(lv_bitstring_or) = ||.
DATA(lv_bitstring_xor) = ||.
DATA(lv_bitstring_not) = ||.
DO 8 TIMES.
DATA(lv_bit) = 0.
GET BIT sy-index OF lv_xa INTO lv_bit.
lv_bitstring_a = lv_bitstring_a && lv_bit.
GET BIT sy-index OF lv_xb INTO lv_bit.
lv_bitstring_b = lv_bitstring_b && lv_bit.
GET BIT sy-index OF lv_hex INTO lv_bit.
lv_bitstring_hex = lv_bitstring_hex && lv_bit.
GET BIT sy-index OF lv_and INTO lv_bit.
lv_bitstring_and = lv_bitstring_and && lv_bit.
GET BIT sy-index OF lv_or INTO lv_bit.
lv_bitstring_or = lv_bitstring_or && lv_bit.
GET BIT sy-index OF lv_xor INTO lv_bit.
lv_bitstring_xor = lv_bitstring_xor && lv_bit.
GET BIT sy-index OF lv_not INTO lv_bit.
lv_bitstring_not = lv_bitstring_not && lv_bit.
ENDDO.
cl_demo_output=>write_data( lv_bitstring_a ).
cl_demo_output=>write_data( lv_bitstring_b ).
cl_demo_output=>write_data( lv_bitstring_hex ).
cl_demo_output=>write_data( lv_bitstring_and ).
cl_demo_output=>write_data( lv_bitstring_or ).
cl_demo_output=>write_data( lv_bitstring_xor ).
cl_demo_output=>write_data( lv_bitstring_not ).
cl_demo_output=>display( ).
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.