REUSE_ALV_GRID_DISPLAY data_changed

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ChampaignWolf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值