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 retrieve the itab displayed in ALV ? I will reward points.

former_member205645
Participant
0 Kudos

Hello Gurus, i am working with a ALV that has some editable columns, but not all. When the user modifies certain columns, some of the non editable columns will modify too.

At the end, when the data must be saved i want to retrieve the hole itab from the ALV; the check_changed_data method will work only for the modified fields but i need everything.

Please help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this code:

CLASS lcl_event_handler IMPLEMENTATION .

  METHOD handle_data_changed .

    PERFORM handle_data_changed USING er_data_changed .

  ENDMETHOD.                    "handle_data_changed

Set handler before creating object for ALV:

*---Register Handle

    SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid .

Form :

FORM handle_data_changed USING ir_data_changed TYPE REF TO cl_alv_changed_data_protocol.

  DATA : ls_mod_cell TYPE lvc_s_modi ,

        lv_value TYPE lvc_value .

  SORT ir_data_changed->mt_mod_cells BY row_id .

  CALL METHOD gr_alvgrid->register_edit_event

    EXPORTING

      i_event_id = cl_gui_alv_grid=>mc_evt_enter

    EXCEPTIONS

      error      = 1

      OTHERS    = 2.

  IF sy-subrc EQ 0.

    LOOP AT ir_data_changed->mt_mod_cells

            INTO ls_mod_cell

            WHERE fieldname = 'NXT_ACT_DATE'.

      CALL METHOD ir_data_changed->get_cell_value

        EXPORTING

          i_row_id    = ls_mod_cell-row_id

          i_fieldname = 'NXT_ACT_DATE'

        IMPORTING

          e_value    = lv_value.

      CALL METHOD ir_data_changed->modify_cell

        EXPORTING

          i_row_id    = ls_mod_cell-row_id

          i_fieldname = ls_mod_cell-fieldname

          i_value    = lv_value.

    ENDLOOP .

  ENDIF.

ENDFORM. " handle_data_changed

Hope it helps you.

All the best.

Regards,

Mukul

Message was edited by: Moshe Naveh

3 REPLIES 3

Former Member
0 Kudos

Hello,

Please see this [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907] at page 49 .

Regards.

Former Member
0 Kudos

create an instance of class CL_ALV_CHANGED_DATA_PROTOCOL

Attribute MP_MOD_ROWS will return the table of the modified rows

Former Member
0 Kudos

Hi,

Try this code:

CLASS lcl_event_handler IMPLEMENTATION .

  METHOD handle_data_changed .

    PERFORM handle_data_changed USING er_data_changed .

  ENDMETHOD.                    "handle_data_changed

Set handler before creating object for ALV:

*---Register Handle

    SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid .

Form :

FORM handle_data_changed USING ir_data_changed TYPE REF TO cl_alv_changed_data_protocol.

  DATA : ls_mod_cell TYPE lvc_s_modi ,

        lv_value TYPE lvc_value .

  SORT ir_data_changed->mt_mod_cells BY row_id .

  CALL METHOD gr_alvgrid->register_edit_event

    EXPORTING

      i_event_id = cl_gui_alv_grid=>mc_evt_enter

    EXCEPTIONS

      error      = 1

      OTHERS    = 2.

  IF sy-subrc EQ 0.

    LOOP AT ir_data_changed->mt_mod_cells

            INTO ls_mod_cell

            WHERE fieldname = 'NXT_ACT_DATE'.

      CALL METHOD ir_data_changed->get_cell_value

        EXPORTING

          i_row_id    = ls_mod_cell-row_id

          i_fieldname = 'NXT_ACT_DATE'

        IMPORTING

          e_value    = lv_value.

      CALL METHOD ir_data_changed->modify_cell

        EXPORTING

          i_row_id    = ls_mod_cell-row_id

          i_fieldname = ls_mod_cell-fieldname

          i_value    = lv_value.

    ENDLOOP .

  ENDIF.

ENDFORM. " handle_data_changed

Hope it helps you.

All the best.

Regards,

Mukul

Message was edited by: Moshe Naveh