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: 

Handler data_changed in ALV

Former Member
0 Kudos
516

Hello All,

I am using the handler Data_changed.

Here the table "er_data_changed" is filled when a field is modified in the alv.

But when the F4 for a field is used, then the "er_data_changed" is getting refreshed i.e, the other old modified value are lost.

I do not want the old modification to be lost.

Thanks,

Nishanth.

1 ACCEPTED SOLUTION

former_member555112
Active Contributor
0 Kudos
282

Hi,

Call the method CHECK_CHANGED_DATA in PAI.

Incase you want to handle the F4 event then create the handler method as follows

METHODS handle_f4

FOR EVENT onf4 OF cl_gui_alv_grid

IMPORTING e_fieldname

e_fieldvalue

es_row_no

er_event_data

et_bad_cells

e_display.

Regards,

Ankur Parab

8 REPLIES 8

former_member555112
Active Contributor
0 Kudos
283

Hi,

Call the method CHECK_CHANGED_DATA in PAI.

Incase you want to handle the F4 event then create the handler method as follows

METHODS handle_f4

FOR EVENT onf4 OF cl_gui_alv_grid

IMPORTING e_fieldname

e_fieldvalue

es_row_no

er_event_data

et_bad_cells

e_display.

Regards,

Ankur Parab

0 Kudos
282

Hello Ankur,

I am not able to understand when to use "check_changed_data" and how does it help.

Thanks,

Kunal.

0 Kudos
282

Hi,

The method Check_changed_data can be called while saving the contents of the modified ALV.


  CALL METHOD g_grid->check_changed_data
    IMPORTING
      e_valid = l_valid.

Regards,

Mansi.

0 Kudos
282

Hello Ankur,

Well the problem is, I am not saving the contents of the ALV to the database until the enter key is pressed. So until then i would like to have all modified data in er_data_changed->mt_good_cells.

As of now, when i change the first data using F4, the change is recorded in er_data_changed->mt_good_cells, but as i go on and modify secong record using F4, the first change is deleted and the new change is only recorded.

Hopefully u have a better picture of my problem now.

Thanks,

kunal.

0 Kudos
282

Hi,

In that case in your handler method call sender->REFRESH_TABLE_DISPLAY.

So that the changed data is passed to teh grid.

regards,

Ankur Parab

0 Kudos
282

Hello Ankur,

I have tried the same. But No success.

Thanks,

Kunal.

I355602
Product and Topic Expert
Product and Topic Expert
0 Kudos
282

Hi,

Refer to the below code snippet:-


**Class Definition
CLASS: lcl_event_receiver DEFINITION DEFERRED.

SET HANDLER v_event_receiver->handle_item_changed FOR v_ref_grid.


CLASS lcl_event_receiver DEFINITION.
  METHODS : 
      handle_item_changed FOR EVENT data_changed_finished
                      OF cl_gui_alv_grid
                      IMPORTING e_modified et_good_cells.
ENDCLASS.                    "lcl_event_receiver DEFINITION

CLASS  lcl_event_receiver IMPLEMENTATION.
*--- modifying updated data in internal table
  METHOD handle_item_changed.
    PERFORM modify_table USING e_modified
                               et_good_cells.

  ENDMETHOD.                    "handle_item_changed
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

In this perform you can use code like:-


FORM modify_table  USING e_modified
                         et_good_cells TYPE lvc_t_modi.

  DATA: ls_good1 TYPE lvc_s_modi.

  READ TABLE et_good_cells INDEX 1 INTO ls_good1.
  IF sy-subrc = 0.
    CASE ls_good1-fieldname.
*--- When Material
      WHEN 'MATNR'. "<--field name
        READ TABLE it_zmm_spice_conv INTO wa_zmm_spice_conv
          INDEX ls_good1-row_id.
        IF sy-subrc = 0.
          wa_zmm_spice_conv-matnr = ls_good1-value.
          MODIFY it_zmm_spice_conv  FROM wa_zmm_spice_conv
            INDEX ls_good1-row_id TRANSPORTING matnr.
        ENDIF.
    ENDCASE.
  ENDIF.
ENDFORM.

Similarly code for other fields (columns) as well.

Hope this helps you.

Regards,

Tarun

Former Member
0 Kudos
282

in that case u need to play with values like this .

*Registering Fields for F4 function.

refresh: gt_f4a.

gt_f4_wa-fieldname = 'BELNR'.

gt_f4_wa-register = 'X'.


  *gt_f4_wa-getbefore  = 'X'.*
  *gt_f4_wa-chngeafter = 'X'.*

.

--> Based on these values , your container get refreshed.

for more info , please check its documentations.

regards

Prabhu