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 Grid: Refresh display when insert new row

Former Member
0 Kudos
1,810

Hi Experts,

I'm using CL_GUI_ALV_GRID. My requirement is: when I click on Standard Insert button, a new row will be added to the grid, I key in, let say PERNR number to the field and press Enter. Upon Enter, I will get the PERNR to retrieve other information and populate that row. I have no problem with capturing the Enter event and get the PERNR. My problem is I dont know how to reflect the result in the newly added row since the added row is not in my internal table yet. If I create a new structure and append it to my internal table, after calling method REFRESH_TABLE_DISPLAY, a new row will be showed, not the one I am editing.

Any idea on how can I update the content of the added row from Insert button?

Thanks for your help! Cheers!

1 ACCEPTED SOLUTION

vinoth_aruldass
Contributor
0 Kudos
384

hi ,

Then the best way for you is to handle the event data_changed_finished instead of data_changed.

The difference between the two is that in data_changed_finished all the values updated in the ALV are updated in the internal table linked to the ALV.

All the updated values are captured in a structure et_good_cells.

The only tricky thing here will be to take the values of the cells you want and put in the work area to update the ZTABLE.

The reason is that in the structure of this variable et_good_cells,every modified cell is added as a new line.

I can just give you a hint to use the fields ROWID,FIELDNAME and VALUE of this variable to build your workarea.

hope my answer will be helpful,

Vinoth Aruldass.

6 REPLIES 6

basarozgur_kahraman
Contributor
0 Kudos
384

Hi Nguyen,

Try to call check_changed_data method of grid.

Ex.

DATA: l_valid TYPE c,

           grid1 type ref to cl_gui_alv_grid.

CALL METHOD grid1->check_changed_data IMPORTING e_valid = l_valid.

0 Kudos
384

Hi Basar,

Thanks for your help! May I know the puporse of using check_changed_data method here? My expected outcome is when I key in PERNR and press Enter, the row contents like Name, Position, etc. will be populated.

0 Kudos
384

Hi Nguyen,

Upon getting pernr data, call this method. After method execution your new row will be added to alv internal table. Then you can populate other fields of row and with modify_cell methods you can set field values of them

vinoth_aruldass
Contributor
0 Kudos
385

hi ,

Then the best way for you is to handle the event data_changed_finished instead of data_changed.

The difference between the two is that in data_changed_finished all the values updated in the ALV are updated in the internal table linked to the ALV.

All the updated values are captured in a structure et_good_cells.

The only tricky thing here will be to take the values of the cells you want and put in the work area to update the ZTABLE.

The reason is that in the structure of this variable et_good_cells,every modified cell is added as a new line.

I can just give you a hint to use the fields ROWID,FIELDNAME and VALUE of this variable to build your workarea.

hope my answer will be helpful,

Vinoth Aruldass.

0 Kudos
384

hi,

Please Check the standard program BCALV_EDIT_04 for your requirement.

In that Check out the following .

methods:

      update_delta_tables

         importing

            pr_data_changed type ref to cl_alv_changed_data_protocol.

Just Run the program BCALV_EDIT_04 and then check the above method it wil help.

0 Kudos
384

Hi Vinoth,

Using data_changed_finished wont help as in this method I wont have access to an instance of CL_ALV_CHANGED_DATA_PROTOCOL, which means I cannot use modify_cell method to update the row detail.   Guess that I will have to handle the thing at data_changed, and manually use modify_cell for each field in the row . Thanks, anyway