2007 Dec 04 1:30 PM
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
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
2007 Dec 04 1: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
2007 Dec 05 4:44 AM
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
2007 Dec 05 8:33 AM
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
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |