SAP Program SAPTREX2 - Example: Tree control in list mode (with documentation)

Description
The program SAPTREX2 is a demonstration of a tree control in list mode.
Each node of the tree is described by the Dictionary structureTREEV_NODE. The field NODE_KEY contains the actual key of the node.
Each node of the tree may contain items. Items are described by theDictionary structure TREEV_ITEM. When you program a tree control, youmust add a character field TEXT (any length) to this structure. Thedemonstration program includes the structure TREEV_ITEM in thestructure MTREEITM, which als contains the TEXT field. The NODE_KEYfield determines the node to which an item belongs, and the fieldITEM_NAME contains the item itself. The only valid entries are wholenumbers >= 1. The items of a node are displayed from left to right. Theroot node (key 'Root') has two items: The first has the class text, andthe text "Root Item 1". In list mode, each item has its own length andjustification. The first item is 15 characters long and left-justified.For the second item ("Root Item 2"), automatic justification has beenenabled. This means that the width of the item is set so that itsentire contents can be displayed.
The root node has a child node with the key 'Child1'. The first item(text "Child 1 Item 1") has the class text, and also has an icon. Thesecond item is a pushbutton with automatic justification. The thirditem is a right-justified text.

Selection
The items of a node can be selected individually. If you click on thefolder or leaf symbol of a node, the system selects the entire node.
You can also configure the tree control so that the entire node isalways selected when you click on it, by setting the ITEM_SELECTIONparameter of the function module TREEV_CREATE to initial).

Events
Events are displayed on the right-hand side of the screen. Thefollowing events can occur in the demonstration program:

node_dbl_clk (node double click)
Double-click on a node. In the demonstration, this is triggered whenyou double-click the folder or leaf symbol. If ITEM_SELECTION is set toSPACE, the event is triggered when you double-click any part of thenode.

item_dbl_click (item double click)
Double-click on an item in the tree. This event can only occur ifITEM_SELECTION = 'X'.

item_context_men
If you click the right mouse button on the tree control, the systemtriggers this event. Its parameters are the node key and the name ofthe item.

node_context_men
If you click the right mouse button while positioned on the folder orleaf symbol, the system triggers this event. Its parameter is the keyof the node.

expand_nc (expand no children)
A node may be configured so that its folder or leaf symbol contains aplus sign even if it has no children (EXPANDER field in TREEV_NODE). Ifthe user clicks one of these nodes, the system triggers the eventEXPAND_NC. In the demonstration, the node "Child1" has this attribute.The demonstratino program reacts to this event by adding two new nodesto the control (New1 and New2).

button_click
The user has clicked an item that is a pushbutton.

link_click
The user has clicked an item that is a link.