Show TOC

add_nodes_and_itemsLocate this document in the navigation structure

Use this method to add nodes and items to the tree. To do this, you need an internal table containing the nodes and items you want to insert.

The node table is processed at the frontend in the order in which you filled it. Consequently, if you insert a node, you must ensure that its parent node has already occurred in the node table.

Caution

Tree control proxy objects (in this case, list_tree or column_tree ) does not itself contain any data. Instead, you use it to transfer data to and from the SAP Tree at the frontend. You must maintain the tree data structure in your application.

CALL METHOD tree->add_nodes_and_items
        EXPORTING node_table            = node_table
                item_table              = item_table
                item_table_structure_name = item_table_structure_name
        EXCEPTIONS failed               = 1
                cntl_system_error       = 2 
                error_in_tables         = 3
                dp_error                = 4
                table_structure_name_not_found = 5.
         

Parameters

Description

node_table

Name of the nodes internal table.

Create the table with reference to treev_ntab .

item_table

Name of the internal table containing the nodes for insertion.

Define the table with reference to a structure of your own.

item_table_structure_name

Name of the structure used to create the internal table for the entries

Filling the Node Table

The node table structure consists of the following fields. You must fill the structure for each node.

node_key

Name of the node you want to define. The name must be a unique key within the tree. The node must not already exist.

relatkey

Name of the related node. This must already be defined in the tree. It must therefore come above the current node in the node table.

If the value is initial, the node is inserted as the root node.

relatship

  • Relationship between node_key and relatkey :

  • tree->relat_first_child ( node_key is inserted as the first child node of node relatkey )

  • tree->relat_first_child ( node_key is inserted as the first child node of node relatkey )

  • tree->relat_prev_sibling ( node_key is inserted before relatkey at the same hierarchy level)

  • tree->relat_prev_sibling ( node_key is inserted after relatkey at the same hierarchy level)

  • tree->relat_first_sibling ( node_key is inserted before all other nodes at the same hierarchy level as relatkey ).

  • tree->relat_last_sibling ( node_key is inserted after all other nodes at the same hierarchy level as relatkey ).

hidden

initial: Node is displayed

'X' : Node is not displayed

disabled

initial: Node can be selected

'X' : Node cannot be selected

isfolder

initial: Node has no subordinate nodes

'X' : Node has subordinate nodes

n_image

Specifies an icon for an unexpanded branch or a leaf:

' ' : Uses a default icon

'@xy@' : Uses the icon with number xy

'BNONE' : No icon. As a result, the display position of the node is brought forwards.

exp_image

Specifies an icon for an expanded branch or a leaf:

' ' : Uses a default icon

'@xy@' : Uses the icon with number xy

'BNONE' : No icon. As a result, the display position of the node is brought forwards.

last_hitem

Name of the last item that you want to appear under the hierarchy heading. (Can only be used with the list tree.)

no_branch

initial: Draws a hierarchy line to the node

'X' : Suppresses the hierarchy line to the node

no_branch

initial: Draws a connecting line to the node.

'X' : Suppresses the connecting line to the node.

expander

initial: Node has no '+' sign for expansion. This setting is only valid for nodes with no child nodes.

'X' : Node must be a branch ( ISFOLDER = 'X' ) and has a '+' sign for expansion. If the user expands a branch that has no children, the event EXPAND_NO_CHILDREN is triggered.

dragdropid

Use this field for a handle to the drag and drop behavior of the node (see also Defining Drag and Drop Events in the SAP Tree ).

Creating the ABAP Dictionary Structure for the Item Table

When you create the ABAP Dictionary structure < my_item >, you must include the structure treev_item and add an extra text field with the name Text . Define the text field using a text type.

Filling the Item Table

node_key

Name of the node to which the item should belong.

item_name

Name of the column in which you want to display this item.

For the list tree, you can use numbers >=1.

In the column tree, specify the previously-defined column.

class

  • tree->item_class_text : Item is text

  • tree->item_class_checkbox : Item as checkbox

  • tree->item_class_button : Item is a pushbutton

  • tree->item_class_link : Item is a link

font

Font:

  • tree->item_font_default : corresponds to tree->item_font_prop in the tree structure but to tree->item_font_fixed in the list tree.

  • tree->item_font_fixed: GUI fixed font

  • tree->item_font_prop : GUI proportional font.

disabled

Deactivates an item

editable

Sets whether an item can be edited

hidden

Sets the visibility of an item

alignment

Alignment of an item (only in list tree)

t_image

Icon for the item

chosen

Checkbox selected

togg_right

You can only use togg_right for items with the class TREE->ITEM_CLASS_CHECKBOX . If TOGG_RIGHT is initial, the checkbox appears to the left of the text. Otherwise, it appears to the right of the text.

style

Style of the item. You can use one of the following styles:

tree->style_default

tree->style_inherited

tree->style_intensified

tree->style_inactive

tree->style_intensified_critical

tree->style_emphasized_negative

tree->style_emphasized_positive

tree->style_emphasized

length

Visible length of the item (only in list tree)

length_pix

Length in pixels (only in list tree)

ignoreimag

Can only be used in the list tree.

initial: LENGTH contains the length of the item text. The width of any checkbox or icon is added to the width of the text.

'X': LENGTH contains the width of the whole item. In this case, icons take up space that would otherwise be occupied by text.

usebgcolor

Can only be used in the list tree.

'X' : The item has a background color that is slightly different to that of the tree control.

initial: The background color is the same.

text

Text for the item.

Note

If the user changes the font, the change does not take effect until the next instantiation of the SAP Tree.

Note

You can address the icon using its name, for example, ICON_ANNOTATION . To do this, the statement INCLUDE <ICON> . must appear in your program.