Skip to Content

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

Weird behave of one event in ALV Tree

Hi,

I have alv tree, where checkbox is in first column. If checkbox is pressed all of the nodes with are childrens are selected.

Two first main nodes are expanded when program starts.

The problem is, that I can't expand others nodes after start of program. (example in picture, I'm sure, that there are some items in that catalog)

When I press checkbox, the items are selected and node is expanded and after that I can collapse and expand node, before that, it's impossible.

Code in class handling event checkbox:

METHOD handle_checkbox.

   DATA:
         lt_nodes_to_sel TYPE lvc_t_nkey,
         lt_selected_nodes TYPE lvc_t_nkey
         .

   FIELD-SYMBOLS:
         <ls_node> LIKE LINE OF lt_nodes_to_sel
                  .

   CALL METHOD lo_alv_tree->get_subtree
     EXPORTING
       i_node_key       = node_key
     IMPORTING
       et_subtree_nodes = lt_nodes_to_sel.


   IF checked = 'X'.
     APPEND LINES OF lt_nodes_to_sel to mt_selected_nodes.

         CALL METHOD lo_alv_tree->set_selected_nodes
       EXPORTING
         it_selected_nodes       = mt_selected_nodes
*  EXCEPTIONS
*    cntl_system_error       = 1
*    dp_error                = 2
*    failed                  = 3
*    error_in_node_key_table = 4
*    others                  = 5
             .
     IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
     ENDIF.


     ELSE.
       loop at lt_nodes_to_sel ASSIGNING <ls_node>.
         DELETE mt_selected_nodes WHERE TABLE_LINE = <ls_node>.
       endloop.

       CALL METHOD lo_alv_tree->unselect_nodes
         EXPORTING
           it_node_key                  = lt_nodes_to_sel
*        EXCEPTIONS
*          cntl_system_error            = 1
*          dp_error                     = 2
*          multiple_node_selection_only = 3
*          error_in_node_key_table      = 4
*          failed                       = 5
*          others                       = 6
               .
       IF sy-subrc <> 0.
*       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.

     ENDIF.

ENDMETHOD.

Code in programi, with may be reason:

APPEND INITIAL LINE TO lt_events ASSIGNING <ls_event>.
   <ls_event>-eventid = cl_gui_column_tree=>eventid_checkbox_change.

   CALL METHOD go_alv_tree->set_registered_events
     EXPORTING
       events                    = lt_events
     EXCEPTIONS
       cntl_error                = 1
       cntl_system_error         = 2
       illegal_event_combination = 3.
   IF sy-subrc <> 0.
*    MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
   ENDIF.

replied

Hello Adam,

You have to add the event  "cl_gui_column_tree=>eventid_expand_no_children". to lt_events.

Regards,

Venkat.

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