‎2008 Feb 08 12:20 PM
Hello Experts.
i have 2 iternal tables itab1 and itab2.
i fetched the data into itab1 and it has 4 fields and itab2 also has 4 fields and fetched the data into it.
loop at itab1.
read table itab2 with key f1 = itab1-f1
f2 = itab2-f2 binary search.
if sy-subrc = 0.
itab2-f3 = itab2-f3 + itab1-f3. " both these fields are same not overflowing
modify table itab2 transporting f3.
endif.
endloop.
this modify statement is not working even though itab2 and itab1 is having header line.please explain
me why this code is not working and also suggest me alternate code.
Thanks for all the replies.
‎2008 Feb 08 12:25 PM
Hi,
Try
MODIFY ITAB2 INDEX SY-TABIX TRANSPORTING F3 .
Since you are within a loop, you need to pin point which record needs to be modified!
Cheers,
Remi
Plz reward points if useful!!
‎2008 Feb 08 12:26 PM
hi Madan,
did you try to debug? One thing is sure: itab2 has to be SORTed before the READ TABLE
ec
‎2008 Feb 08 12:26 PM
Hi,
Try to change your code like this....
modify table itab2 index sy-tabix transporting f3.
Rgds,
Bujji
‎2008 Feb 08 12:26 PM
check this and revert if probs occurs.
sort itab1 by f1 f2 ascending.
sort itab2 by f1 f2 ascending.
data:wk_tabix type sy-tabix.
loop at itab1.
read table itab2 with key f1 = itab1-f1 f2 = itab2-f2 .
if sy-subrc = 0.
wk_tabix = sy-tabix.
itab2-f3 = itab2-f3 + itab1-f3.
modify table itab2 index wk_tabix transporting f3.
endif.
endloop.
‎2008 Feb 08 12:28 PM
Hi,
Did u sort the iternal table1 by f1 f2 before reading it...
Regards,
Kaveir
‎2008 Feb 08 12:41 PM
TRY USING THIS
loop at itab1.
loop at itab2 where f1 = itab1-f1 and f2 = itab2-f2 .
itab2-f3 = itab2-f3 + itab1-f3.
modify table itab2.
endloop.
endloop.
‎2008 Feb 08 2:27 PM
Hi madan,
lot of replies, lot of - to say it politically correct - not necessarily helpful answers.
Correct answer: Must use INDEX addition for modify. Only in a loop you do not need an index.
In rare cases, F1 on modify may help:
[Internal tables: Changing Lines|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm]
See the section Changing Table Lines Using the Index. They say Without the INDEX addition, you can only use the above statement within a LOOP
Regards,
Clemens