Google Search - Blog...........

ABAP - Modifying Internal Table In A Loop Using Index

report ztest.

types: begin of ttab ,
vbeln(10) type c ,
vkorg(4) type c,
dele(4) type c,
end of ttab ,

begin of ttab1 ,
vbeln(10) type c,
dele(4) type c,
end of ttab1 .


data: itab type table of ttab with header line,
itab1 type table of ttab1 with header line,
wa like line of itab ,
wa1 like line of itab1 .

data:v_index type sy-index .



itab-vbeln = '0000000001'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .

itab-vbeln = '0000000002'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .

itab-vbeln = '0000000003'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .


itab1-vbeln = '0000000001'.
itab1-dele = 'TST'.
append itab1 .

itab1-vbeln = '0000000002'.
itab1-dele = 'GRE'.
append itab1 .



sort itab by vbeln.
sort itab1 by vbeln.
loop at itab into wa.

v_index = sy-tabix.
read table itab1 into wa1 with key vbeln = wa+0(10).
wa+14(4) = wa1+10(4).
modify itab index v_index from wa .

endloop.

loop at itab.
write:/ itab-vbeln,itab-vkorg,itab-dele .
endloop.

No comments:

Post a Comment