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

Default field values in editable ALV grid using custom container

Former Member
0 Likes
1,946

Hi,

Can anyone please suggest how can a default a particular field value say cost element  when the user enters another field on the same row say tax code and hits enter button.My output is an editable ALV grid which is using custom containers.The code is a ALV OOP.

Thanks

Sarita Panda

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,092

Hi Sarita,

Below are the steps to achieve this functionality.

1. Register the event:

*--for tab    

     CALL METHOD go_alv->register_edit_event

         EXPORTING

           i_event_id = cl_gui_alv_grid=>mc_evt_modified.

*-- for enter

       CALL METHOD go_alv->register_edit_event

         EXPORTING

           i_event_id = cl_gui_alv_grid=>mc_evt_enter.

2. Get the changed row,with this below code your changed data row will be selected :


     CALL METHOD go_alv->check_changed_data.

3. Handle the event:


    

     SET HANDLER go_respond_events->handle_data_changed_finish FOR go_alv.

4. You have to create the class for this before. In this class you have to update that value:

CLASS respond_events DEFINITION FINAL .

   PUBLIC SECTION .

     METHODS: handle_data_changed_finish FOR EVENT data_changed_finished

              OF cl_gui_alv_grid.

ENDCLASS .                    "respond_events definition

CLASS respond_events IMPLEMENTATION .

   METHOD handle_data_changed_finish.

     LOOP AT <your intarnal tablewhich used for display> INTO <ls_>.

      **just update the corresponding field of the field symbol here table will be updated

     ENDLOOP.

   ENDMETHOD. "handle_data_changed

ENDCLASS .               "respond_events implementation

Regards,

Supratik




Hi,

Can anyone please suggest how can a default a particular field value say cost element  when the user enters another field on the same row say tax code and hits enter button.My output is an editable ALV grid which is using custom containers.The code is a ALV OOP.

Thanks

Sarita Panda

2 REPLIES 2
Read only

Former Member
0 Likes
1,092

Hi Sarita,

You can use the event DATA_CHANGED to check the value entered for a particular cell.

And in the same event you can update the value too.

    METHODS handle_data_changed                 " DATA_CHANGED

      FOR EVENT data_changed OF cl_gui_alv_grid

        IMPORTING

          er_data_changed

          e_onf4

          e_onf4_before

          e_onf4_after

          e_ucomm.

*   ENTER key is pressed or

    CALL METHOD go_grid->register_edit_event

      EXPORTING

        i_event_id = cl_gui_alv_grid=>mc_evt_enter.


In this event you will get 2 methods in  er_data_changed

One er_data_changed->GET_CELL_VALUE to read the value of a cell

Second er_data_changed->MODIFY_CELL to change the value of cell.

Regards,

Read only

Former Member
0 Likes
1,093

Hi Sarita,

Below are the steps to achieve this functionality.

1. Register the event:

*--for tab    

     CALL METHOD go_alv->register_edit_event

         EXPORTING

           i_event_id = cl_gui_alv_grid=>mc_evt_modified.

*-- for enter

       CALL METHOD go_alv->register_edit_event

         EXPORTING

           i_event_id = cl_gui_alv_grid=>mc_evt_enter.

2. Get the changed row,with this below code your changed data row will be selected :


     CALL METHOD go_alv->check_changed_data.

3. Handle the event:


    

     SET HANDLER go_respond_events->handle_data_changed_finish FOR go_alv.

4. You have to create the class for this before. In this class you have to update that value:

CLASS respond_events DEFINITION FINAL .

   PUBLIC SECTION .

     METHODS: handle_data_changed_finish FOR EVENT data_changed_finished

              OF cl_gui_alv_grid.

ENDCLASS .                    "respond_events definition

CLASS respond_events IMPLEMENTATION .

   METHOD handle_data_changed_finish.

     LOOP AT <your intarnal tablewhich used for display> INTO <ls_>.

      **just update the corresponding field of the field symbol here table will be updated

     ENDLOOP.

   ENDMETHOD. "handle_data_changed

ENDCLASS .               "respond_events implementation

Regards,

Supratik