Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV and Lead Selection

Dear experts,

what i want to do:

i have an ALV that displays me a lot of columns. I have a "delete" button too.

so when i mark a line and click on delete i want to delete the line.

My problem is that i can´t get the lead selection. I tried like this:

it worked with a normal table ui element.

please help

thanks and best regards


  • navigate from <CONTEXT> to <WORKLIST_TABELLE> via lead selection

lo_nd_worklist_tabelle = wd_context->get_child_node( name = wd_this->wdctx_worklist_tabelle ).

lead_selection = lo_nd_worklist_tabelle->get_lead_selection( ).

if lead_selection is initial.

l_cmp_api = wd_comp_controller->wd_get_api( ).

l_window_manager = l_cmp_api->get_window_manager( ).

move 'löschen ohne Selektion nicht möglich' to text.

append text to lt_text.

clear text.


Former Member

Hi Rene,

The procedure to delete the selected row in ALV is the same as in a normal table ui element. Check the code fragment below:

DATA:  wd_node TYPE REF TO if_wd_context_node,
   lr_element TYPE REF TO if_wd_context_element.

" Get access to the desired context node
  wd_node = wd_context->get_child_node( name = 'NODE' ).

" Get the lead selection of the ALV
  lr_element = wd_node->get_lead_selection( ).

" Remove the element obtained through lead selection
  wd_node->remove_element( EXPORTING element = lr_element ).

The above coding is working perfectly fine for me. Just ensure that the lead selection property has not been disabled for your ALV. For example I use the below coding to enable multiple row selection for my ALV and disable lead selection property for the ALV.

 data: lr_table_settings  TYPE REF TO if_salv_wd_table_settings.
" Setting the ALV selection to multiple selection with no lead selection
 lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).

Now then if I were to try delete multiple rows from the ALV I use the following coding for the same:

METHOD onactiondelete_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
         lr_element  TYPE REF TO if_wd_context_element,
         lt_element  TYPE wdr_context_element_set.

  wd_node = wd_context->get_child_node( name = 'NODE' ).

  CALL METHOD wd_node->get_selected_elements
      set = lt_element.

  LOOP AT lt_element INTO lr_element.
    wd_node->remove_element( EXPORTING element = lr_element ).




0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question