SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for Byte String Processing → Byte String Functions →Bit Functions
The example demonstrates how bit-set works.
Source Code
REPORT demo_bit_set.
SELECTION-SCREEN BEGIN OF SCREEN 100.
PARAMETERS number TYPE i.
SELECTION-SCREEN END OF SCREEN 100.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA: hex TYPE xstring,
txt TYPE string.
DO.
CALL SELECTION-SCREEN 100 STARTING AT 10 10.
IF sy-subrc = 0.
IF ABS( number ) <= 200.
hex = BIT-SET( number ).
txt = hex.
MESSAGE txt TYPE 'I'.
ELSE.
MESSAGE 'Number in Example must not exceed 200'
TYPE 'I'
DISPLAY LIKE 'E'.
ENDIF.
ELSE.
RETURN.
ENDIF.
ENDDO.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
The output of the program shows how bits are set a specified position and how the result is assigned to a byte string whose content is represented by a text string.