Function alv的先将data change 的事件名字及form名字放到gt_event中然后传到Function中,最后在perform中写对应的代码即可,参考如下:
DATA:
ls_layout TYPE lvc_s_layo.
DATA: i_grid_settings TYPE lvc_s_glay.
DATA: gt_events TYPE slis_t_event,
gs_event TYPE slis_alv_event.
i_grid_settings-edt_cll_cb = 'X'.
ls_layout-zebra = 'X'.
* ls_layout-cwidth_opt = 'X'.
ls_layout-ctab_fname = 'CELLTAB'.
ls_layout-box_fname = 'SEL'.
MOVE 'DATA_CHANGED' TO gs_event-name.
MOVE 'DATA_CHANGED' TO gs_event-form.
APPEND gs_event TO gt_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_PF_STATUS_SET'
i_callback_user_command = 'FRM_USER_COMMAND'
i_grid_settings = i_grid_settings
is_layout_lvc = ls_layout
it_fieldcat_lvc = gt_fieldcat
it_events = gt_events
TABLES
t_outtab = gt_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM data_changed USING p_er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
FIELD-SYMBOLS:<fs_out> TYPE gy_out.
DATA: ls_zpp_mot_mps_list TYPE zpp_mot_mps_list.
DATA: ls_modi TYPE lvc_s_modi.
DATA: l_grid TYPE REF TO cl_gui_alv_grid.
DATA: ls_stable TYPE lvc_s_stbl.
ls_stable-row = 0.
ls_stable-col = 0.
LOOP AT p_er_data_changed->mt_good_cells INTO ls_modi.
READ TABLE gt_out ASSIGNING <fs_out> INDEX ls_modi-row_id .
IF sy-subrc = 0.
IF ls_modi-fieldname = 'GSTRP_C'.
<fs_out>-gstrp_c = ls_modi-value.
<fs_out>-icon_change = icon_led_yellow.
<fs_out>-edit = 'U'.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->refresh_table_display
EXPORTING
is_stable = ls_stable.
CLEAR p_er_data_changed->mt_good_cells.
ENDFORM. " DATA_CHANGED