简体   繁体   English

删除 ALV 中的选定行

[英]Delete selected row in ALV

I have ALV table and I made a custom button in the table toolbar.我有 ALV 表格,我在表格工具栏中做了一个自定义按钮。 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.    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM