10-02-2008 9:01 AM
Hi frirnds,
I need to modify a internal table under the loop of a another internal table... Presen, I am doing this as..
loop at itab1.
read table itab2 with key (Some condition)....
itab2-f1 = xxx.
modify itab2 index sy-tabix from itab2.
Is the way i am approaching is correct...Because sy-tabix shows the record no of itab1, but i need to modify itab2.... Should i use sy-tabix or sy-index here....if i wont use any of that its going toshort dump..so i think i need to use an index...Pls sugest me...
Thanks,
Shyam.
10-02-2008 9:04 AM
In F1 help for statement READ TABLE :
SY-TABIX is set to the index of the entry.
regards,
Hans
10-02-2008 9:06 AM
Hi,
Store the index directly after the read for use later like.
Loop at itab1.
read itab2 with key...
if sy-subrc = 0.
lv_tabix = sy-tabix.
else.
clear lv_tabix.
endif.
....
...
if lv_tabix <> 0.
modify itab2 index lv_tabix.
endif.
endloop.
Darren
10-02-2008 9:20 AM
Hi Shyam Prasad,
You can use SY-TABIX.
Because you want the index of the record that satisfies the condition in SECOND internal table.
Initially, SY-TABIX has the index from FIRST inernal table.
After READ in SECOND internal table, it will be changed that is the value we want to modify in it.
Use it within IF SY-SUBRC = 0... ENDIF.
Regards,
R.Nagarajan.
10-02-2008 9:23 AM
Hi...
Check this code..
Declare one variable..
loop at itab.
n = n + 1.
read table itab2 with key f1 = itab-f1.
if sy-subrc = 0.
itab2-f2 = 'XXX'.
modify itab2 index n.
endif.
Thanks,
Naveen.I
10-02-2008 9:25 AM
I would do it in a modern way avoiding such discussions and with more performance:
data:
tab1 type standard table of t1,
tab2 type standard table of t2.
field-symbols:
<p1> type t1,
<p2> type t2.
loop at tab1 assigning <p1>.
read table tab2 assigning <p2> where.....
if sy-subrc = 0.
<p2>-field = 'ABCDE'.
endif.
endloop.
No doubt with sy-tabix.