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: 

How to capture user entered values from an input enabled ALV grid?

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

Take a look at the programs BCALV_EDIT_01 to BCALV_EDIT_08 in package SLIS.

regards,

Advait

Former Member
0 Kudos

Deja vu?

Didn't i read the exact same question in another forum?

MarcinPciak
Active Contributor
0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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