07-03-2007 5:59 PM
Hi all,
Is it possible to modify a internal table in some other internal table's Loop.
In a loop of ITAB , i am moving some fields to IT_FINAL , and trying to Modify IT_FINAL , but it showing dump, so is it possible to modify or append some internal table in some other internal table's Loop , pls suggest some solution.
Thanks in advance,
Regards,
Vivek
07-03-2007 6:02 PM
Yes you can modify but you need mention the index as addition.
E.g : MODIFY itab INDEX index1.
So increment a counter in loop & use it in modify statement
07-03-2007 6:02 PM
Yes you can modify but you need mention the index as addition.
E.g : MODIFY itab INDEX index1.
So increment a counter in loop & use it in modify statement
07-03-2007 6:02 PM
Yes - you heve to specify the proper position in the itab (SY-TABIX).
Rob
07-03-2007 6:06 PM
Can u explain by some example , how to give index or sy-tabix value
07-03-2007 6:10 PM
Hi, try this
DATA: BEGIN OF ti_scustom OCCURS 0.
INCLUDE STRUCTURE scustom.
DATA: END OF ti_scustom.
DATA: ti2 LIKE TABLE OF ti_scustom WITH HEADER LINE.
SELECT * FROM scustom INTO TABLE ti_scustom.
ti2[] = ti_scustom[].
LOOP AT ti_scustom.
IF sy-tabix = 2.
ti2-name = 'Paisante'.
MODIFY ti2 index sy-tabix.
ENDIF.
ENDLOOP.
READ TABLE ti2 with key id = 2.
WRITE ti2.
Regards
07-03-2007 6:10 PM
<b>data : v_tabix liek sy-tabix.</b>
loop at itab1.
<b>v_tabix = sy-tabix.</b>
loop at itab2 where field1 eq itab1-field1.
move-corresponding itab2 to itab1.
<b>modify itab1 index v_tabix.</b>
endloop.
endloop.
07-03-2007 6:10 PM
Hi,
You need to use index addition if you want to modify an internal table during its LOOP operations.
Use sy-tabix if you want to modify the current record of an internal table.
Reward points if the answer is helpful.
Regards,
Mukul
07-04-2007 4:04 AM
Hi,
Can you please paste your code here?
How you are accessing it_final?
are you readig It_final using a key from itab? if so store that index in a field idx and modify it_final with this idx.
ie.
read table it_final with key *****.
if sy-subrc = 0.
idx = sy-tabix.
it_final-field1 = itab-field1.
modify it_final index idx from it_final transporting field1.
endif.
the other approach is modify table it_final from is_final. "where is_final is workarea
with regards,
Vamsi
07-04-2007 4:10 AM
Vivek,
1.Check the data type of source and target fields.Bath should same type.
2. put below logic.
LOOP AT ITAB.
it_final-field1 = itab-field1.
modify it_final index idx from it_final transporting field1.
ENDLOOP.
Don't forget to reward if useful...
07-04-2007 5:21 AM
Hi,
you can also use the following:
loop at itab1 into wa_tab1.
move wa_tab1-field1 to lwa_results_final-msgtxt.
move wa_tab1-field2 to lwa_results_final-msgid.
move wa_tab1-field3 to lwa_results_final-msgno.
modify li_results_final from lwa_results_final
transporting msgtxt msgid msgno
where ordkey = 'testvariable'.
endloop.
Regards,
Sooness