Skip to Content

How to select and deselect all the check boxes in ALV tree at node and item level?

Hi All,

I developed an OOABAP ALV TREE report with check boxes at node level and item level...

and there are two buttons 1. Select All

2.Deselect All

if I select the button SelectALL all the checkboxes have to be selected and

if select the button Deselect ALL all the checkboxes have to be Deselected .

if any of you had solution to this...

Please help to get the desired functionality....


Vasantha D

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2013 at 05:09 AM


    You need to add a button to the toolbar manually, when the button is pressed loop at all the nodes that have a checkbox and update the checkbox field.

    Something like....

    data: go_tree1 type ref to cl_gui_alv_tree,
    go_toolbar type ref to cl_gui_toolbar

    * Add buttons to the toolbar
    call method go_tree1->get_toolbar_object
    er_toolbar = go_toolbar.

    check go_toolbar is not initial.

    call method go_toolbar->add_button
    fcode = 'SELALL'
    icon = icon_select_all
    butn_type = cntb_btype_button
    text = ''
    quickinfo = 'Select All'.

    * Define an event handler
    data: go_receiver type ref to lcl_event_receiver.

    class lcl_event_receiver definition.
    public section.
    function_selected for event function_selected of cl_gui_toolbar
    importing fcode.

    class lcl_event_receiver implementation.
    method function_selected.
    case fcode.
    when 'SELALL'.
    perform select_all.

    * Register the event
    create object go_receiver.
    set handler go_receiver->function_selected for go_toolbar.

    form select_all.

    data: lv_field type lvc_fname.

    * Update the checkbox on each node of the ALV tree
    lv_field = 'CHECK'. "Whatever you've called the checkbox

    call method go_tree1->change_item
    i_node_key = node_key "<-- loop at the nodes and repeat for each one with a checkbox
    i_fieldname = lv_field
    i_data = ' '
    node_not_found = 1
    others = 2.

    call method go_tree1->frontend_update. "call this onces all updates have been made


    hope it helps,


    Add a comment
    10|10000 characters needed characters exceeded

    • Ok Thanks for your idea.

      I created the check box at node level and item level by using the below code

      DATA : ls_node TYPE lvc_s_layn.

      DATA : l_node_text TYPE lvc_value,

      ls_tab TYPE itab.

      * set item-layout

      DATA: lt_item_layout TYPE lvc_t_layi,

      ls_item_layout TYPE lvc_s_layi.

      CLEAR ls_item_layout.

      ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.

      ls_item_layout-editable = 'X'.

      ls_item_layout-style =


      ls_item_layout-fieldname = gr_alv_tree->c_hierarchy_column_name.

      APPEND ls_item_layout TO lt_item_layout.

      * add node

      CLEAR l_node_text.

      l_node_text = p_ls_gas_wk_confcust-customer.

      CLEAR ls_node.

      ls_node-n_image = space.

      ls_node-exp_image = space.

      CALL METHOD gr_alv_tree->add_node


      i_relat_node_key = p_relat_key

      i_relationship = cl_gui_column_tree=>relat_last_child

      i_node_text = l_node_text

      * is_outtab_line = ls_gas_wk_confcust

      is_node_layout = ls_node

      it_item_layout = lt_item_layout


      e_new_node_key = p_node_key .

      with this code in some looping internal table

      i am getting the check box at node level and item level...

      I am new to create checkboxes at node and item level...

      Please suggest me

      In order to select or deselect the check boxes by which field based i can do?


      Vasantha D.

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.