I think that these functions behave strange.
I have made local class method for EVENT data_changed OF cl_gui_alv_grid where I try to use the table er_data_changed->mt_inserted_rows to update my internal table.
But if I for example have 4 rows in the alv, and I mark line 3 and press the insert row button, then then a blank line will be inserted at row 3 and push the old rows 3 and 4 to row 4 and 5.
So far so good. But the row_id in the mt_inserted_rows will be set to 5 indication that the new row is row number 5 and this is useless - or did I miss something.
I want to insert a blank record in my internal table at the same row as it was inserted in the alv (that is in row 3), but how can I know that it was in fact row 3 and not row 5 that was newly inserted.
I have same problem whit the Duplicate row function (&LOCAL©_ROW).
Thomas Madsen Nielsen
Please check the following code.
rows TYPE lvc_t_row,
row_id TYPE lvc_t_roid,
w_row LIKE LINE OF row_id.
CALL METHOD grid->get_selected_rows
et_index_rows = rows
et_row_no = row_id.
LOOP AT row_id INTO w_row.
READ TABLE t_sflight INDEX w_row-row_id INTO fs_sflight.
perform the necessary operations.
insert fs_SFLIGHT into t_tab index w_row-row_id .
HERE YOU WILL GET THE INDEX WHERE THE OPERATION HAS BEEN PERFORMED ON THE TABLE.
FS_SFLIGHT CONTAINES THE NEW RECORD JUST CREATED.
HERE THE RECORD WILL BE INSERTED IN THE SPECIFIED INDEX OF THE INTERNAL TABLE.
T_TAB IS THE INTERNAL TABLE FOR THE ACTUAL ALV TABLE.
Regards and Best wishes.