
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.
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 |
|
|
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 |
|
|
font |
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. |
If the user changes the font, the change does not take effect until the next instantiation of the SAP Tree.
You can address the icon using its name, for example, ICON_ANNOTATION . To do this, the statement INCLUDE <ICON> . must appear in your program.