Application Development and Automation 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: 
Read only

ALV using methods. Capturing editable cell data.

Former Member
0 Likes
1,393

Hi, I have created ALV grid using container. I have made one of the cells as editable. Now how can i capture the edited data.

5 REPLIES 5
Read only

Former Member
0 Likes
1,121

Hi,

Check this program BCALV_FIELDCAT_TEST

If you implement the DATA_CHANGED event you can get the information of what cell and what is the value changed.

data_changed for event data_changed

of cl_gui_alv_grid

importing er_data_changed "<---This holds the information

e_onf4

e_onf4_before

e_onf4_after,

er_data_changed is of type CL_ALV_CHANGED_DATA_PROTOCOL, so here you can find the Following information from the attributes of the object.

MT_MOD_CELLS

MP_MOD_ROWS

MT_GOOD_CELLS

MT_DELETED_ROWS

MT_INSERTED_ROWS

Hope this helps

Read only

0 Likes
1,121

Thanks a lot for the reply. Could you tell me when this event will exactly get triggered?? I have assigned an event handler and wrote an event handler method but its not getting triggered. Actually in my case the editable field is a check box. when the user checks a box and clicks on a custom push button on the application tool bar, it should navigate to a transaction. But this event is not getting triggered. If you can help me asap please ping me on . Expecting your fast reply.

thanks

Vishnu

Read only

0 Likes
1,121

Hi,

As we can now make our ALV Grid editable we may require controlling input data. The ALV Grid has events u201Cdata_changedu201D and u201Cdata_changed_finishedu201D. The former method is triggered just after the change at an editable field is perceived. Here you can make checks for the input. And the second event is triggered after the change is committed.

You can select the way how the control perceives data changes by using the method u201Cregister_edit_eventu201D. You have two choices:

i. After return key is pressed: To select this way, to the parameter u201Ci_event_idu201D pass u201Ccl_gui_alv_grid=>mc_evt_enteru201D.

ii. After the field is modified and the cursor is moved to another field: For this, pass u201Ccl_gui_alv_grid=>mc_evt_modifiesu201D to the same parameter.

To make events controlling data changes be triggered, you must select either way by calling this method. Otherwise, these events will not be triggered.

To control field data changes, ALV Grid uses an instance of the class u201CCL_ALV_CHANGED_DATA_PROTOCOLu201D and passes this via the event u201Cdata_changedu201D. Using methods of this class, you can get and modify cell values and produce error messages.

In Sy-ucomm, when you click the SAVE button, call the method like this.

WHEN 'SAVE'.

DATA w_ref1 TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = w_ref1.

CALL METHOD w_ref1->check_changed_data.

CALL METHOD w_ref1->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_modified.

Hope this wud help

Read only

0 Likes
1,121

This message was moderated.

Read only

0 Likes
1,121

Hi Vishnu,

try the below options..

Have u used

DATA gr_event_handler TYPE REF TO lcl_event_handler .

.. ..

*--Creating an instance for the event handler

CREATE OBJECT gr_event_handler .

*--Registering handler methods to handle ALV Grid events

SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid .

SET HANDLER gr_event_handler->handle_data_changed_finished FOR gr_alvgrid .

CASE sy-ucomm.

WHEN 'SAVE'.

  • to reflect the data changed into internal table

DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

IF ref_grid IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref_grid.

ENDIF.

IF NOT ref_grid IS INITIAL.

CALL METHOD ref_grid->check_changed_data.

ENDIF.

ENDCASE.

"User command module at PAI:

CASE gd_okcde. WHEN 'SWITCH'.

" switch editable / non-editable PERFORM switch. ...

FORM switch. "(1) Read current fieldcatalog

go_grid->get_frontend_layout( ). "(2) Mark / Unmark EDIT flag in fieldcatalog

LOOP AT gt_fcat INTO ls_fcat WHERE ( fieldname = '<name of column>' ). " which you want to edit

IF ( ls_fcat-edit = 'X' ).

ls_fcat-edit = space.

ELSE.

ls_fcat-edit = 'X'.

ENDIF.

MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix. ENDLOOP. "(3) Set modified fieldcatalog:

go_grid->set_frontend_layout( ).

ENDFORM.

also have a look on the below programs

BCALV_EDIT_01

BCALV_EDIT_02

BCALV_EDIT_03

BCALV_EDIT_04

BCALV_EDIT_05

BCALV_EDIT_06

BCALV_EDIT_07

BCALV_EDIT_08

Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell to status "editable".

Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell to status "non-editable".