04-07-2011 6:34 AM
Hi,
I need a way to simulate binary addition on abap: example
000
001
010
011
100
so if i add 1, then the next value is 101. the lenght would also vary from 2 to 8.
ex. 2
00
01
10
11
I would need this for mass uploading the release statuses for PO. i would use this as an internal table to finaly map it on T16FK (Release statuses)
04-07-2011 10:13 PM
Hello c z,
See Code below.
Kind Regards,
Rae Ellen Woytowiez
REPORT zbinary_addition.
DATA: offset TYPE i,
power TYPE i.
DATA: inc TYPE i.
DATA: help_base10 TYPE i,
answer_binary(8) TYPE n,
temp_power TYPE i.
DATA: wa_t16fk TYPE t16fk.
START-OF-SELECTION.
inc = 1.
WHILE inc <= 255.
*
* Convert decimal number to binary.
answer_binary = '000000000'.
offset = 0.
power = 7.
temp_power = 2 ** power.
help_base10 = inc.
WHILE help_base10 > 0.
IF help_base10 >= temp_power.
answer_binary+offset(1) = '1'.
help_base10 = help_base10 - temp_power.
ENDIF.
IF help_base10 > 0.
power = power - 1.
offset = offset + 1.
temp_power = 2 ** power.
ENDIF.
ENDWHILE.
wa_t16fk-FRGA1 = answer_binary(1).
wa_t16fk-FRGA2 = answer_binary+1(1).
wa_t16fk-FRGA3 = answer_binary+2(1).
wa_t16fk-FRGA4 = answer_binary+3(1).
wa_t16fk-FRGA5 = answer_binary+4(1).
wa_t16fk-FRGA6 = answer_binary+5(1).
wa_t16fk-FRGA7 = answer_binary+6(1).
wa_t16fk-FRGA8 = answer_binary+7(1).
inc = inc + 1.
ENDWHILE.
Edited by: Rae Ellen Woytowiez on Apr 8, 2011 4:53 PM
Edited by: Rae Ellen Woytowiez on Apr 8, 2011 4:55 PM
04-13-2011 3:18 AM
amazing! I don't pretend to understand all of this but it is enough for me to have it modified to fit my code. thanks!
11-30-2011 12:01 PM