Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SET BIT

Former Member
0 Likes
560

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

3 REPLIES 3
Read only

matt
Active Contributor
0 Likes
460

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

Read only

Former Member
0 Likes
460

Thank you very much Matthew .

can you give me some example where i can still analyze the operation of "set bit"

Message was edited by:

priya latha

Read only

matt
Active Contributor
0 Likes
460

Do you understand binary representation? And how to convert between hex, decimal and binary? If not, read <a href="http://en.wikipedia.org/wiki/Binary_numeral_system">this</a>. Above what I've already explained, there's not really much else to say. And you shouldn't worry about it too much. BITwise operations are very rarely used in ABAP.

matt