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: 

Data_changed event not capturing changed data on ALV grid after F4

Former Member
0 Kudos

Hi All,

I have handled the F4 event on an ALV grid. The values are copied back correctly to the grid. But the changed values are not

being captured at all in the event Changed_data.

When I enter the values manually, by typing, the values are getting captured. I have handled all the required stuff like, set handler for event, registering the evt_modified, registering the fields for F4.

Any clue on if I am missing anything here.

Thanks a lot in advance for the inputs.

Regards.

5 REPLIES 5

0 Kudos

Hi,

Please check calling the method CHECK_CHANGED_DATA of grid in the PAI of the screen.

Regards,

SPR

Former Member
0 Kudos

Try it before CHECK_CHANGED_DATA.

ls_stable-row  = 'X'.

ls_stable-col  = 'X'.

l_soft_refresh = space.


call method Grid->refresh_table_display

       exporting

         is_stable      = ls_stable

         i_soft_refresh = l_soft_refresh.


R

Former Member
0 Kudos

Hi all,

I have already put in all these stuff and it did work.

Made this work with a workaround.

Thanks & regards,

Y Gautham.

0 Kudos

IN GRID YOU HAVE TO PASS THE I_APPL_EVENTS = 'X'.

THEN IT WILL WORK AFTER YOU DID ABOVE STUFF.

samudrala_rakesh
Explorer
0 Kudos

Hi,

Check The below code For reacting changed data on output.

CLASS lcl_events DEFINITION.

  PUBLIC SECTION.

    METHODS:on_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid

            IMPORTING  e_row_id e_column_id es_row_no,



            handle_data_change FOR EVENT data_changed OF cl_gui_alv_grid

              IMPORTING er_data_changed.



ENDCLASS.                    "lcl_events DEFINITION

METHOD  handle_data_change.

    DATA : lw_good  TYPE lvc_s_modi.

*    break pwc_004.

    LOOP AT er_data_changed->mt_good_cells INTO lw_good.

      CASE lw_good-fieldname.

        WHEN 'UNIT'.

          READ TABLE gt_final INTO gw_final INDEX lw_good-row_id.

          IF sy-subrc EQ 0.

            gw_final-unit = lw_good-value.

            READ TABLE gt_mseg INTO gw_mseg WITH KEY mblnr = gw_final-mblnr

                                                     zeile = gw_final-zeile.

            IF sy-subrc EQ 0.

              gw_unit = lw_good-value.

              PERFORM cal_cons_value USING gw_unit.

            ENDIF.

            MODIFY gt_final FROM gw_final INDEX lw_good-row_id TRANSPORTING unit menge meins cons_value.

          ENDIF.

*          go_grid->refresh_table_display( ).

        WHEN OTHERS.

      ENDCASE.

    ENDLOOP.

Creating object of container

    CREATE OBJECT go_cont

      EXPORTING

        container_name = 'CONT'.



    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

*Creating object of alv

    CREATE OBJECT go_grid

      EXPORTING

        i_parent = go_cont

        i_appl_events = 'X'.

IF go_grid IS BOUND.

      CALL METHOD go_grid->set_table_for_first_display

        EXPORTING

          is_layout                     = gw_layo     " Layout

        CHANGING

          it_outtab                     = gt_final    " Output Table

          it_fieldcatalog               = gt_fcat  " Field Catalog

        EXCEPTIONS

          invalid_parameter_combination = 1

          program_error                 = 2

          too_many_lines                = 3

          OTHERS                        = 4.

      IF sy-subrc <> 0.

        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ENDIF.

*  ***To set the event handler for hotspot event and data change event

      CREATE OBJECT lo_obj.

      SET HANDLER lo_obj->on_hotspot_click FOR go_grid.

      SET HANDLER lo_obj->handle_data_change FOR go_grid.

* * Registering the EDIT Event

      CALL METHOD go_grid->register_edit_event

        EXPORTING

          i_event_id = cl_gui_alv_grid=>mc_evt_modified

        EXCEPTIONS

          error      = 1

          OTHERS     = 2.

      IF sy-subrc <> 0.

        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ENDIF.

    ENDIF.

  ELSE.

    CALL METHOD go_grid->refresh_table_display.

  ENDIF.

Thanks