‎2008 Jul 15 9:08 PM
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
‎2008 Jul 15 9:11 PM
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
‎2008 Jul 15 9:12 PM
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
‎2008 Jul 15 9:15 PM
"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.
‎2008 Jul 15 9:22 PM
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