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

modify statement is not working

Former Member
0 Likes
785

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.

7 REPLIES 7
Read only

RemiKaimal
Active Contributor
0 Likes
753

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!!

Read only

JozsefSzikszai
Active Contributor
0 Likes
753

hi Madan,

did you try to debug? One thing is sure: itab2 has to be SORTed before the READ TABLE

ec

Read only

Former Member
0 Likes
753

Hi,

Try to change your code like this....

modify table itab2 index sy-tabix transporting f3.

Rgds,

Bujji

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
753

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.

Read only

Former Member
0 Likes
753

Hi,

Did u sort the iternal table1 by f1 f2 before reading it...

Regards,

Kaveir

Read only

former_member609120
Contributor
0 Likes
753

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.

Read only

Clemenss
Active Contributor
0 Likes
753

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