删除ALV中的选定行 [英] Delete selected row in ALV

查看:743
本文介绍了删除ALV中的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ALV表格,并且在表格工具栏中做了一个自定义按钮。每当按下按钮时,我都想删除所选的行。现在只显示一条消息,这样我就可以查看自定义按钮是否正常工作。

I have ALV table and I made a custom button in the table toolbar. Whenever the button is pressed, I want to delete the selected row. Now there's just a message showing up so I could see if the custom button is working.

METHOD on_user_command.
CASE e_salv_function.
  WHEN 'MYFUNC1'.
    MESSAGE i301(z_global) WITH 'Function 1'.
    *Right here the row should be deleted.


  WHEN 'MYFUNC2'.
    MESSAGE i301(z_global) WITH 'Function 2'.
  WHEN OTHERS.
ENDCASE.
ENDMETHOD.


推荐答案

下面是删除所选行的示例代码:

Here is the sample code for deleting selected row:

CASE e_salv_function.
 WHEN 'MYFUNC1'.
  PERFORM delete_lines.
  ...
 ENDCASE.   

form delete_lines.
  data: sav_tabix type lvc_index.
  clear row_table.
  call method grid1->get_selected_rows( et_index_rows = data(row_table) ).

      loop at gt_outtab.
        sav_tabix = sav_tabix + 1.
        read table row_table with key index = sav_tabix.
        if sy-subrc = 0.
          delete gt_outtab INDEX sav_tabix.
        endif.
      endloop.

  call method grid1->refresh_table_display.
  call method cl_gui_cfw=>flush.
endform.    

这篇关于删除ALV中的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆