‎2008 Jan 10 2:15 AM
Hi all,
i got 5 record in my internal table. How can i modify the data in the 4th record.
Assume 4th record now is 'abc'. i want to change it to 'xyz'. My internal still contain 5 records.
How can i do it?
Thks
‎2008 Jan 10 2:19 AM
‎2008 Jan 10 2:19 AM
‎2008 Jan 10 2:25 AM
Okie..What happen if i duno the index no but only a certain value in the itab field
assume i know the field itab-admino
i want to modify the field itab-name from 'gary' to 'peter'.
How can i do it? thks.
‎2008 Jan 10 2:29 AM
basically the fool proof way is to read the table using the READ statement based on some KEY field, then move the new value to the field, and MODIFY it using the WA and specifing the INDEX.
read table itab into wa with key admino = '12345'.
if sy-subrc = 0.
itab-name = 'Peter'.
modify itab from wa index sy-tabix.
endif.
Regards,
Rich Heilman
‎2008 Jan 10 2:38 AM
‎2008 Jan 10 2:39 AM
‎2008 Jan 10 2:51 AM
i test the program. But the value still remain unchanged. Below is my code. Pls help me to look thru . Thk.
Data : Begin of itab occurs 10.
firstname(30) type c,
lastname(30) type c,
End of itab.
Data: wa like line of itab.
*Add some value to the itab
itab-firstname = 'gary'.
itab-lastname = 'chen'.
append itab.
itab-firstname = 'pete'.
itab-lastname = 'zhang'.
append itab.
read table itab into wa with key firstname = 'pete'.
if sy-subrc = 0.
itab-lastname = 'lin'.
modify itab from wa index sy-tabix.
endif.
*check the itab for lastname change
loop at itab.
write: / itab-firstname.
write: itab-lastname.
endloop.
result: i still gt back the lastname as 'zhang' instead of the modify value 'lin'.
Pls help . Thank
‎2008 Jan 10 3:03 AM
‎2008 Jan 10 2:19 AM
describe table TAB lines N. " N gives the no of rows in ITAB
read table ITAB index N-1. " supposing that you wnat to edit the last but one record
IF sy-subrc = 0.
ITAB-FIELD1 = 'XYZ'.
modify ITAB.
clear : ITAB.
ENDIF. Regards
Gopi
‎2008 Jan 10 2:22 AM
Assumed your table is itab and the tables workarea is ls_wa
ls_wa = 'xyz'.
modify itab from ls_wa index 4.
That's it.
Regards,
Michael