Application Development 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: 

Modify Example

Former Member
0 Kudos

Hey Folks,

I have a problem when using modify . in my requirement I have table itab and itab1

following is the below code

loop at itab into wa_itab.

read table it_itab1 into wa_itab1 with key vbeln = wa_itab-a binary search.

if sy-subrc = 0.

wa_tab-b = wa_itab1-b

endif.

modify it_itab1 from wa_itab1.

endloop.

how can the change the contents of ITAB1.

I am getting a short dump saying i cant modify the table while inserting.

Thanks

Larry

4 REPLIES 4

Former Member
0 Kudos

Hi,

Try this one

loop at itab into wa_itab.

read table it_itab1 into wa_itab1 with key vbeln = wa_itab-a binary search.

if sy-subrc = 0.

wa_tab-b = wa_itab1-b

endif.

modify table it_itab1 from wa_itab1.

endloop.

Cheers

Kothand

Former Member
0 Kudos

Try this:

LOOP AT itab INTO wa_itab.
  READ TABLE it_itab1 INTO wa_itab1 WITH KEY vbeln = wa_itab-a BINARY
  SEARCH.
  IF sy-subrc = 0.
    wa_tab-b = wa_itab1-b.
  ENDIF.
  MODIFY it_itab1 FROM wa_itab1 INDEX sy-tabix.
ENDLOOP.

Rob

former_member156446
Active Contributor
0 Kudos

"declare field symbols. using this you will get good 
performance bcoz you can remove modify statement 
completely..

loop at itab assigning <fs_itab>.
read table it_itab1 assigning <fs_itab1> with key vbeln = <fs_itab>-a binary search.
if sy-subrc = 0.
<fs_tab>-b = <fs_itab1>-b
endif.

endloop.

Former Member
0 Kudos

Hi Larry ,

In the code you are assigning the value of itab1 to itab

i.e.

wa_tab-b = wa_itab1-b

means you are changing contents of itab table and not itab1.

So you should move the contents from itab to itab1.

wa_tab1-b = wa_itab-b

and in modify statement use transporting field.

i.e.

modify it_itab1 from wa_itab1 transporting b where a = wa_itab-a.

where b is field of table.

Best regards,

Brijesh