Skip to Content
author's profile photo Former Member
Former Member

SET BIT

Good Evening to all,

can anybody explains me how SET BIT bitpos OF byte_string [TO val] get works.

I concluded that it will set the bit of position (bitpos) of string (byte_string).

buti am nt getting how it works ?

can anybody briefly explains me how this get works and how this program works?

DATA hex TYPE x LENGTH 1.

DO 8 TIMES.

CLEAR hex.

SET BIT sy-index OF hex. "how it works

WRITE hex.

ENDDO.

output is: 80 40 20 10 08 04 02 01

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 04, 2007 at 01:40 PM

    Through each loop iteration, the variable hex is cleared, so contains binary value 00000000.

    First time through the loop. sy-index is 1, and so bit 1 is set, so you have binary value 00000001. Which is hex 01.

    Next time through the loop, sy-index is 2, and so bit 2 is set, so you have binary value 00000010. Which is hex 02.

    Next time through the loop, sy-index is 3, and so bit 3 is set, so you have binary value 00000100. Which is hex 04.

    and so on.

    matt

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.