10-08-2008 3:46 PM
Hi,
I have an input enabled ALV grid, which has 4 columns. First column is prepopulated with 5 rows of data, other 3 columns are input enabled out of which 1 column has checkbox.
Now I want to read the data entered by user.
How do I get my internal table populated with the ALV's current data?
I am using OO to build the ALV.
Thank You in advance.
SAC.
10-08-2008 6:29 PM
Hi,
Define a class as a event receiver for data_changed or data_changed_finished events. Here is how to implement the latter method:
CLASS cl_alv_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
cell_changed FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells.
ENDCLASS.
CLASS cl_alv_event_receiver IMPLEMENTATION.
METHOD cell_changed.
check e_modified = 'X'. "if content of cell was changed
"here you check et_good_cells table, it will contain new values
"it is of type lvc_t_modi
...
ENDMETHOD.
ENDCLASS.
CREATE OBJECT cl_alv_event_receiver.
"now just indicate the handler for this event
SET HANDLER cl_avl_event_receiver->cell_changed FOR cl_gui_alv_grid.
Each time some action was perfomed on edit field, the method will be invoked and you can check inside what was changed and what is the new value.
Regards
Marcin
10-08-2008 3:48 PM
Take a look at the programs BCALV_EDIT_01 to BCALV_EDIT_08 in package SLIS.
regards,
Advait
10-08-2008 5:15 PM
10-08-2008 6:29 PM
Hi,
Define a class as a event receiver for data_changed or data_changed_finished events. Here is how to implement the latter method:
CLASS cl_alv_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
cell_changed FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells.
ENDCLASS.
CLASS cl_alv_event_receiver IMPLEMENTATION.
METHOD cell_changed.
check e_modified = 'X'. "if content of cell was changed
"here you check et_good_cells table, it will contain new values
"it is of type lvc_t_modi
...
ENDMETHOD.
ENDCLASS.
CREATE OBJECT cl_alv_event_receiver.
"now just indicate the handler for this event
SET HANDLER cl_avl_event_receiver->cell_changed FOR cl_gui_alv_grid.
Each time some action was perfomed on edit field, the method will be invoked and you can check inside what was changed and what is the new value.
Regards
Marcin
10-09-2008 11:30 AM
Hi,
Here is the code i have written.
CLASS cl_alv_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
cell_changed FOR EVENT data_changed_finished OF cl_gui_alv_grid IMPORTING e_modified et_good_cells.
ENDCLASS.
CLASS cl_alv_event_receiver IMPLEMENTATION.
METHOD cell_changed.
check e_modified = 'X'.
ENDMETHOD.
ENDCLASS.
DATA : W_ALV_EVENT TYPE REF TO CL_ALV_EVENT_RECEIVER.
CREATE OBJECT w_alv_event.
SET HANDLER w_alv_event->cell_changed FOR w_rogrid.
How to check the table et_good_cells for values.
If i put a break point in the method cell_changed, its not stopping.
Thanks.
10-09-2008 12:27 PM
It is beacuse the event is not triggered.
What is w_rogrid in this statement?
SET HANDLER w_alv_event->cell_changed FOR w_rogrid.
Write this instead of above:
SET HANDLER w_alv_event->cell_changed FOR cl_gui_alv_grid. "if you want to set handler for all alv instances
"or
SET HANDLER w_alv_event->cell_changed FOR your_avl_object. "if you want to set handler only for your object.
Regards
Marcin
10-09-2008 12:48 PM
Marcin,
If i write CL_GUI_ALV_GRID instead of w_rogrid, i am getting the following syntax error
"Field "CL_GUI_ALV_GRID" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement"
I am not getting syntax error if i am writing "w_rogrid" in place of CL_GUI_ALV_GRID.
w_rogrid is the reference variable of class CL_GUI_ALV_GRID.
Thanks,
Ibrahim