Skip to Content
author's profile photo Former Member
Former Member

Selecting all rows in ALV on a button click


I have a dynamic ALV table. I also have a button 'Select All Rows'. On clicking the button I want all the rows in the ALV table selected. Similarly I want to deselect all the rows if I click another button 'Deselect All Rows'.

Is it possible to do this way? Is there a similar functionality already existing in ALV component?

Thanks & Regards,


Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 21, 2007 at 09:17 PM

    In addition to setting the Table Selection to MULTI -

    Create a Function on ALV ToolBar with a Button 'Select All'

    When it is pressed, get all the element count of the node and set all to selected.

    data lv_count type i

    lv_count = Node->get_element_count( ).

    Do lv_count times.

    Node->Set_Selected( sy-index ).


    Similarly create a button for 'Deselect All'

    When it is pressed, clear the selection

    Node->clear_selection( ).

    Add a comment
    10|10000 characters needed characters exceeded

    • I have an application where I want to select everything initially.

      I cannot get it to select the first row.

      The demo program has a table populated from SCARR.

      The entire code is in WDDOINIT:

      method WDDOINIT .

      data lo_cmp_usage type ref to if_wd_component_usage.

      data: lr_node type ref to if_wd_context_node,

      lr_scarr_alv type ref to iwci_salv_wd_table,

      lr_model type ref to cl_salv_wd_config_table,

      lr_table_settings type ref to if_salv_wd_table_settings,

      lt_elements type wdr_context_element_set,

      lr_element like line of lt_elements.

      • Create the component.

      lo_cmp_usage = wd_this->wd_cpuse_alv_grid( ).

      if lo_cmp_usage->has_active_component( ) is initial.

      lo_cmp_usage->create_component( ).


      • Get a reference to the ALV component, then to the model.

      lr_scarr_alv = wd_this->wd_cpifc_alv_grid( ).

      lr_model = lr_scarr_alv->get_model( ).

      lr_table_settings ?= lr_model.

      • Set selection mode to MULTI.

      lr_table_settings->set_selection_mode( cl_wd_table=>e_selection_mode-multi_no_lead ).

      • Now select them all.

      lr_node = wd_context->get_child_node( 'SCARR' ).

      lt_elements = lr_node->get_elements( ).

      loop at lt_elements into lr_element.

      lr_element->set_selected( abap_true ).



      Where am I going wrong? Doesn't matter what I do to it, the first element is never selected.

      Edited by: Russell Day on Jan 31, 2008 11:01 AM

      Edited by: Russell Day on Jan 31, 2008 11:03 AM

  • author's profile photo Former Member
    Former Member
    Posted on Aug 20, 2007 at 09:57 AM


    This feature is inbuilt in the ALV. You need to enable multiple selection in your ALV by using the method IF_SALV_WD_TABLE_SETTINGS~set_selection_mode. You can then see a toggle button for select/deselect all in the top left corner of your ALV grid.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.