Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV functions to insert records (&LOCAL©_ROW and &LOCAL&INSERT_ROW)

TMNielsen
Contributor
0 Kudos

Hi

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&COPY_ROW).

best regards

Thomas Madsen Nielsen

1 ACCEPTED SOLUTION

ennowulff
Active Contributor
0 Kudos

The data changed object has a table where ALV-Rows and table-rows are matched:

CL_ALV_CHANGED_DATA_PROTOCOL->MT_ROID_FRONT

Watch in Debugger at event "Data_Changed".

This might answer your confusions...

3 REPLIES 3

ennowulff
Active Contributor
0 Kudos

The data changed object has a table where ALV-Rows and table-rows are matched:

CL_ALV_CHANGED_DATA_PROTOCOL->MT_ROID_FRONT

Watch in Debugger at event "Data_Changed".

This might answer your confusions...

Former Member
0 Kudos

Hi,

Please check the following code.



 DATA:
          rows TYPE lvc_t_row,
          row_id TYPE lvc_t_roid,
          w_row LIKE LINE OF row_id.
         CALL METHOD grid->get_selected_rows
            IMPORTING
            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 .
          ENDLOOP.
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.

TMNielsen
Contributor
0 Kudos

Thanks for your replies.

I'm sorry - i didn't find time to try the suggested solutions yet, so I just marked your posts as helpful answers - without knowing if they really are.

I close the thread.