report zdemo03.
type-pools: slis.
data:gt_t001 like table of t001.
data: git_fieldcat type slis_t_fieldcat_alv,
gwa_layout type slis_layout_alv.
data:
o_grid type ref to cl_gui_alv_grid,
gt_events type slis_t_event,
gs_events like line of gt_events.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_event_receiver definition.
public section.
methods data_changed
for event data_changed of cl_gui_alv_grid
importing er_data_changed.
endclass.
data gt_event_receiver type ref to lcl_event_receiver .
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_event_receiver implementation.
method data_changed .
perform frm_data_changed using er_data_changed.
endmethod.
endclass.
start-of-selection.
perform out_data.
*&---------------------------------------------------------------------*
*& Form OUT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form out_data.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_structure_name = 'T001'
i_inclname = sy-repid
changing
ct_fieldcat = git_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2.
select *
from t001
into corresponding fields of table gt_t001
up to 20 rows.
**************定义事件FORM名称*********************
gs_events-name = 'CALLER_EXIT'.
gs_events-form = 'CALLER_EXIT'.
append gs_events to gt_events.
gwa_layout-edit = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
is_layout = gwa_layout
it_fieldcat = git_fieldcat
it_events = gt_events
tables
t_outtab = gt_t001
exceptions
program_error = 1.
endform. "OUT_DATA
*&---------------------------------------------------------------------*
*& Form caller_exit
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E_GRID text
*----------------------------------------------------------------------*
form caller_exit using e_grid type slis_data_caller_exit.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = o_grid.
call method o_grid->register_edit_event "注册GRID事件
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter"事件:回车
exceptions
error = 1
others = 2.
create object gt_event_receiver.
set handler gt_event_receiver->data_changed for o_grid.
endform. "CALLER_EXIT
*&---------------------------------------------------------------------*
*& Form frm_data_changed
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IR_DATA_CHANGED text
*----------------------------------------------------------------------*
form frm_data_changed using ir_data_changed
type ref to cl_alv_changed_data_protocol.
data : ls_mod_cell type lvc_s_modi,
lv_value type lvc_value.
clear:ir_data_changed->mt_inserted_rows.
delete gt_t001 where bukrs eq ''.
data stbl type lvc_s_stbl.
stbl-row = 'X'." 基于行的稳定刷新
stbl-col = 'X'." 基于列稳定刷新
call method o_grid->refresh_table_display
exporting
is_stable = stbl.
endform. " FRM_DATA_CHANGED
阅读(1485) | 评论(0) | 转发(0) |