04-26-2006 10:35 AM
Hi all, I have this problem,
I have an ALV built with the OOP, I have an editable quantity fields, and a totals related to it.
When I modify the quantity the totals doesn't refresh correctly, I have tried to force the refresh of the ALV but I was not able to solve this problem.
Thank you
04-26-2006 11:09 AM
Hello,
You must be using the method handle_data_changed to monitor the change data event.
This method populated the changed data in table er_data_changed.
Use this table to capture the modified fields and read the internal table values corresponding to that row, and update your internal table. Then refresh the ALV display.
This way, you are reverting the updated values to your internal table and thus both ER_DATA_CHANGED table and ITAB are in sync.
Please consider sample code below :
*Handler to Check the Data Change
handle_data_changed FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed
e_onf4
e_onf4_before
e_onf4_after.
Method Implementation
METHOD handle_data_changed.
PERFORM handle_data_changed USING er_data_changed.
ENDMETHOD. "HANDLE_DATA_CHANGED
____________________________________________
FORM handle_data_changed USING p_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA : l_mod_cell TYPE lvc_s_modi,
l_value TYPE lvc_value,
l_field TYPE lvc_fname.
SORT p_data_changed->mt_mod_cells BY row_id.
LOOP AT p_data_changed->mt_mod_cells INTO l_mod_cell where fieldname = 'AUFNR'.
CALL METHOD p_data_changed->get_cell_value
EXPORTING i_row_id = l_mod_cell-row_id
i_fieldname = 'AUFNR'
IMPORTING e_value = l_value .
Read ITAB for field
READ TABLE ITAB INDEX l_mod_cell-row_id.
if sy-subrc eq 0.
replace value with changed value from ALV Grid
itab-aufnr = l_value.
update itab.
endif.
Refresh ALV Grid
CALL METHOD gr_alvgrid->refresh_table_display
ENDFORM.
04-26-2006 10:47 AM
Hi,
Please go through the link below if it can help you.
<a href="http://www.sapfans.com/forums/viewtopic.php?t=84933">http://www.sapfans.com/forums/viewtopic.php?t=84933</a>
<a href="http://www.sapfans.com/forums/viewtopic.php?t=69878">http://www.sapfans.com/forums/viewtopic.php?t=69878</a>
Please reward some points if it helps.
Regards,
Amit Mishra
04-26-2006 10:55 AM
Hi,
when I used the DEFUALT REFRESH button on the toolbar, it changed the totals as well.
TRY doing this.
CALL THE CHECK_CHANGED_DATA IN THE pai and then use the REFRESH_TABLE_DISPLAY method.
Regards,
Ravi
Note : Please mark the helpful answers
Message was edited by: Ravikumar Allampallam
04-26-2006 10:50 AM
Hi,
once you modify the content of the alv grid you need to check the internal table is with the new data or not. if it is not then repopulate the data and then call the refresh method.
04-26-2006 11:09 AM
Hello,
You must be using the method handle_data_changed to monitor the change data event.
This method populated the changed data in table er_data_changed.
Use this table to capture the modified fields and read the internal table values corresponding to that row, and update your internal table. Then refresh the ALV display.
This way, you are reverting the updated values to your internal table and thus both ER_DATA_CHANGED table and ITAB are in sync.
Please consider sample code below :
*Handler to Check the Data Change
handle_data_changed FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed
e_onf4
e_onf4_before
e_onf4_after.
Method Implementation
METHOD handle_data_changed.
PERFORM handle_data_changed USING er_data_changed.
ENDMETHOD. "HANDLE_DATA_CHANGED
____________________________________________
FORM handle_data_changed USING p_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA : l_mod_cell TYPE lvc_s_modi,
l_value TYPE lvc_value,
l_field TYPE lvc_fname.
SORT p_data_changed->mt_mod_cells BY row_id.
LOOP AT p_data_changed->mt_mod_cells INTO l_mod_cell where fieldname = 'AUFNR'.
CALL METHOD p_data_changed->get_cell_value
EXPORTING i_row_id = l_mod_cell-row_id
i_fieldname = 'AUFNR'
IMPORTING e_value = l_value .
Read ITAB for field
READ TABLE ITAB INDEX l_mod_cell-row_id.
if sy-subrc eq 0.
replace value with changed value from ALV Grid
itab-aufnr = l_value.
update itab.
endif.
Refresh ALV Grid
CALL METHOD gr_alvgrid->refresh_table_display
ENDFORM.
04-26-2006 11:24 AM