Using the Simple Tree

Use

This section lists the functions that are specific to the simple tree.

Prerequisites

The process described here is an extension of the general process for using controls that is specific to the simple tree. It does not contain all of the steps required to produce a valid instance of the control.

Process

Creating the Instance

  1. Define a reference variable for the simple tree:

    DATA simple_tree TYPE REF TO cl_gui_simple_tree. 
  2. Create an instance of the tree control:

    
    CREATE OBJECT simple_tree
     EXPORTING
      parent               = container
      node_selection_mode  = node_selection_mode
      hide_selection       = hide_selection
    
     EXCEPTIONS
      lifetime_error               = 1
      cntl_system_error            = 2
      create_error                 = 3
      failed                       = 4
      illegal_node_selection_mode  = 5.

Register the Events

Register the events for the simple tree. The control supports the following events:

Event Name

Meaning

NODE_DOUBLE_CLICK

User double-clicked a node

EXPAND_NO_CHILDREN

Node without children was expanded

SELECTION_CHANGED

The selected node has changed

NODE_CONTEXT_MENU_REQUEST

Request of a context menu for a node

NODE_CONTEXT_MENU_SELECT

User selected an entry from the context menu

DEFAULT_CONTEXT_MENU_REQUEST

User requested a context menu with the cursor positioned on an empty space in the control

DEFAULT_CONTEXT_MENU_SELECT

User selected an entry from the context menu

KEYPRESS

User pressed a predefined key.

Using the Simple Tree

  1. Add nodes to the tree. To do this, fill a node table, then pass it to the control using the add_nodes method:

    
    CALL METHOD simple_tree->add_nodes
     EXPORTING
      table_structure_name  = table_structure_name
      node_table            = node_table
            
     EXCEPTIONS
      error_in_node_table            = 1
      failed                         = 2
      dp_error                       = 3
      table_structure_name_not_found = 4.

Change existing nodes in the tree, or change the tree attributes (see Changing the Attribtues of the Control).

Query any necessary attributes of the tree and its nodes (see Finding Out the Attributes of the Control).

Destroying the Control

  • Destroy the custom control at the front end. If you do not need the control container any more, destroy it as well:

    CALL METHOD simple_tree->free.
  • Delete the reference variables to the simple tress and the control container, if required.

    FREE simple_tree.