1.Introduction
In the abap how to refresh alv internal table in the alv by click ‘x’? I will demostrate it in next example. The purpose is that add the other logic in ohter alv field.
2 Example
data it_events type table of slis_alv_event.
data lw_event type slis_alv_event.
data lw_guid type lvc_s_glay.
lw_guid-edt_cll_cb = 'X'.
lw_event-name = 'DATA_CHANGED'.
lw_event-form = 'FRM_DATA_CHANGE'.
append lw_event to it_events.
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_USER_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
is_layout_lvc = ls_layout
it_fieldcat_lvc = lt_fieldcat
i_save = 'A'
i_grid_settings = lw_guid
it_events = it_events
tables
t_outtab = gt_alv
exceptions
program_error = 1
others = 2.
form frm_data_change using rr_data_changed type ref to cl_alv_changed_data_protocol.
data: l_name type char20,
lw_stable type lvc_s_stbl,
ls_cells type lvc_s_modi.
data: l_grid type ref to cl_gui_alv_grid. "用来获取最新值
data l_message type char100.
data:l_date type sy-datum.
data: lt_ztfi083b like table of ztfi083b.
data: lw_ztfi083b like line of lt_ztfi083b .
data:lv_change_flag(1).
*设置ALV刷新时的焦点,避免每次刷新都自动跳到第一列
lw_stable-row = 0.
lw_stable-col = 0.
field-symbols: <dyn_wa> type any,
<fs> type any.
* 取当前ALV信息
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = l_grid.
loop at rr_data_changed->mt_mod_cells into ls_cells. "读取被修改了的单元格
read table gt_alv into gw_alv index ls_cells-row_id.
case ls_cells-fieldname.
when 'SEL'.
gw_alv-sel = ls_cells-value.
if s_time is not initial.
clear:l_date,lw_ztfi083b.
select single * into lw_ztfi083b
from ztfi083b
where zlcbh = gw_alv-zlcbh.
if lw_ztfi083b is not initial.
gw_alv-datbi = lw_ztfi083b-datna + s_time .
l_date = sy-datum.
if gw_alv-datbi < l_date.
gw_alv-zenid = 'N'.
else.
gw_alv-zenid = 'Y'.
endif.
endif.
endif.
when others.
endcase.
modify gt_alv from gw_alv index ls_cells-row_id .
endloop.
call method l_grid->refresh_table_display
exporting
is_stable = lw_stable. "刷新ALV
clear rr_data_changed->mt_good_cells.
endform.
3 Summary
3.1 Add the code
We add it and the data can be changed.
data lw_guid type lvc_s_glay.
lw_guid-edt_cll_cb = 'X'.
3.2 Take function.
The FM ' REUSE_ALV_GRID_DISPLAY ' is not use event .
3.3 Input field
As long as you input field in the alv, we will write logic in the field. Otherwrise it is empty.