01-22-2019 2:32 PM
Hello,
Have an Input enabled ALV Grid (CL_GUI_ALV_GRID). In the Event DATA_CHANGED I want to set a value in some other cells depended on the User Input. For that I use the method MODIFY_CELL( ) of parameter ER_DATA_CHANGED (CL_ALV_CHANGED_DATA_PROTOCOL). However the Value I want to pass is not taken over and indeed at the end of the MODIFY_CELL( ) I see for me not very understandable code were indeed the value gets lost:
ls_modi-row_id = i_row_id.
ls_modi-tabix = i_tabix.
ls_modi-fieldname = i_fieldname.
* ls_modi-value = i_value.
clear ls_modi-value.
append ls_modi to mt_good_cells.
append ls_modi to mt_mod_cells.
endif.
endif.
Anybody an idea how to prevent this?
Dirk
01-22-2019 3:03 PM
Is your actual code executed in some handle method of event data_changed of cl_gui_alv_grid, are you reading changed data in some LOOP AT er_data_changed->mt_good_cells, then for each changed cell after an initial call of get_cell_value to get changed value do you call modify_cell, on same row_id, with another field name?
01-22-2019 7:38 PM
If you use MODIFY_CELL, you should only change the values which exist in MT_GOOD_CELLS.
Otherwise, you should directly change MT_MOD_CELLS and MT_GOOD_CELLS, eventually by using the method alv_grid->SET_DELTA_CELLS (although it's marked "for internal use only").
01-23-2019 1:19 AM
i think there is very good example on how to handle data_change event: BCALV_EDIT_03, you should read it.
for now you append a new record into mt_good_cells, but its not how it work. if you want to change another cell in the same row, you should use method MODIFY_CELL of ER_DATA_CHANGED, something like:
LOOP AT er_data_changed->mt_good_cells INTO DATA(ls_good).
CASE ls_good-fieldname.
WHEN 'your changed field'.
er_data_changed->modify_cell(
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = 'field you want to change'
i_value = 1 " Value you want to input
).
WHEN OTHERS.
ENDCASE.
ENDLOOP.
01-23-2019 2:45 PM
Hello,
All thanks for your input but couldn't get it to work that way.
BUT found a simple solution which is at least sufficient for my Use-Case: Data checks are still done in the event
DATA_CHANGED, but the updates I do now in the event DATA_CHANGED_FINISHED and there directly in ALV-Data Table.
I can think that in some (extreme?) use cases this might not be sufficient. I.e. when you want also the Data_Changed event to be triggered for the changes you now make directly in the Data Table.