ALV中data changed事件刷新内表

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.

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值