某一单元格被修改后,相同订单号的其他行的相同单元格也要自动更新为修改值
利用data_changed 事件
首先定义回车事件
DATA :lt_events TYPE slis_t_event,
ls_events TYPE slis_alv_event.
CLASS: lcl_event_handler DEFINITION DEFERRED.
DATA : gr_event_receiver TYPE REF TO lcl_event_handler.
CLASS lcl_event_handler DEFINITION. "类定义
PUBLIC SECTION.
METHODS:
handle_data_changed "新订单数量更改事件
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS.
接着类的实现
CLASS lcl_event_handler IMPLEMENTATION. "类实现
METHOD handle_data_changed.
PERFORM data_changed USING er_data_changed.
ENDMETHOD.
ENDCLASS.
编写data_changed 内容
FORM data_changed USING p_er_data_changed
TYPE REF TO cl_alv_changed_data_protocol.
DATA: ls_stbl TYPE lvc_s_stbl.
DATA : l_tabix TYPE sy-tabix .
FIELD-SYMBOLS: <f_value> TYPE lvc_s_modi-value .
FIELD-SYMBOLS: <f_field> TYPE any .
DATA : ls_modi TYPE lvc_s_modi .
* 这里将无法捕捉到的变更的数据,更新至内表
LOOP AT p_er_data_changed->mt_good_cells INTO ls_modi .
READ TABLE gt_alv ASSIGNING FIELD-SYMBOL(<f_data>) INDEX ls_modi-row_id .
ASSIGN ls_modi-value TO <f_value> .
ASSIGN COMPONENT ls_modi-fieldname OF STRUCTURE <f_data> TO <f_field> .
IF sy-subrc EQ 0 .
<f_field> = <f_value> .
ENDIF.
LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<fs_change>) WHERE aufnr = <f_data>-aufnr .
<fs_change>-checkbox = <f_data>-checkbox .
<fs_change>-xwemng = <f_data>-xwemng .
<fs_change>-tldatum = <f_data>-tldatum .
<fs_change>-fldatum = <f_data>-fldatum .
ENDLOOP .
ls_stbl = 'XX'.
CALL METHOD grid->refresh_table_display
EXPORTING
is_stable = ls_stbl.
ENDLOOP.
ENDFORM.
不能忘的一步,把该事件放入 FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'中
在DEFINE中添加
ls_events-name = ls_events-form = 'DATA_CHANGED'.
APPEND ls_events TO lt_events.