Skip to Content

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

ALV Tree with checked checkboxes

Hello colleagues,

I have built a ALV Tree with checkboxes.While running the ALV Tree it is no problem to retrieve all checked items from the object "CL_GUI_ALV_TREE".

(With the method GET_CHECKED_ITEMS)

But no I have the situation that some items have to checked when you START the ALV Tree. Unfortunately I do not find a method like "SET_CHECKED_ITEMS"...

Can you please help me?

Thanks a lot.

Best regards,


Edited by: Rick Weigel on Jul 22, 2008 8:57 AM


Hello Rick

To create an entire new class for such a simple problem is an overkill. Take the sample report BCALV_TREE_DEMO. Routine ADD_COMPLETE_LINE adds the lines to the ALV tree containing the checkbox. Here you have to add a single statement:

*&      Form  add_cmplete_line
*       add hierarchy-level 3 to tree
*      -->P_LS_SFLIGHT  sflight
*      -->P_RELEATKEY   relatkey
*     <-->p_node_key    new node-key
form add_complete_line using   ps_sflight type sflight
                               p_relat_key type lvc_nkey
                     changing  p_node_key type lvc_nkey.

  data: l_node_text type lvc_value.

* set item-layout
  data: lt_item_layout type lvc_t_layi,
        ls_item_layout type lvc_s_layi.
  ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
  ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
  ls_item_layout-editable = 'X'.
  ls_item_layout-chosen   = 'X'.  " <<<< That's all.
  append ls_item_layout to lt_item_layout.

  clear ls_item_layout.
  ls_item_layout-fieldname = 'PLANETYPE'.
  ls_item_layout-alignment = cl_gui_column_tree=>align_right.
  append ls_item_layout to lt_item_layout.

  l_node_text =  ps_sflight-fldate.

  data: ls_node type lvc_s_layn.
  ls_node-n_image   = space.
  ls_node-exp_image = space.

  call method tree1->add_node
      i_relat_node_key = p_relat_key
      i_relationship   = cl_gui_column_tree=>relat_last_child
      is_outtab_line   = ps_sflight
      i_node_text      = l_node_text
      is_node_layout   = ls_node
      it_item_layout   = lt_item_layout
      e_new_node_key   = p_node_key.
endform.                               " add_complete_line

Of course you need to add your logic which nodes should be marked and which not.



1 View this answer in context

Helpful Answer

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