Programme SAP SAPTLIST_TREE_CONTROL_DEMO - Example: List Tree Control (with Documentation)

Description
This program demonstrates the list tree control (classCL_GUI_LIST_TREE).
Each node in the tree is described by the ABAP Dictionary structureTREEV_NODE. The NODE_KEY field contains the key of the node.
Each node in the tree can posess items, each of which is described bythe ABAP Dictionary structure TREEV_ITEM, to which the programmer mustadd a character field TEXT (of any length). In the example program,TREEV_ITEM is included in the structure MTREEITM, which, in addition,contains a field TEXT. The NODE_KEY field determines the node to whichan item belongs. ITEM_NAME contains the name of the item. This fieldmay only contain integer values from 1 upwards. The items of a node aredisplayed from left to right.
The example shows some important attributes of the list tree control:

  • Objects" tem: This item has proportional font ITEM-FONT =
  • CL_GUI_LIST_TREE=>ITEM_FONT_PROP). You should only use proprortionalfont for an item if the width of the item is automatically adjusted tothe length of the text string (so that the string always fits!). Inorder to do this, the ALIGNMENT field of the item must contain thevalue CL_GUI_LIST_TREE=>ALIGN_AUTO.
    • The items in the third and fourth nodes contain a tabular construction.
    • For this to work, the first three items of each node must have a fixedlength (ITEM-ALIGNMENT = CL_GUI_LIST_TREE=>ALIGN_LEFT, ITEM-LENGTH =...) and you must use a fixed font for the items. (ITEM-FONT =ITEM_FONT_FIXED).

      Selection
      Items in a node can be selected individually. When you click the folderor leaf symbol of a node, the entire node is selected.
      You can set the selection behavior of the tree so that clicking thenode always selects the entire node. To do this, set the ITEM_SELECTIONparameter of the constructor method to initial.

      Events
      The program displays events as they occur on the right-hand side of thescreen. The following events can be triggered in the example program:

      node_dbl_clk (node double click)
      Double click on a node. In the example, this event is triggered whenyou double-click the folder/leaf symbol. If ITEM_SELECTION is set toSPACE, the event is triggered when you double-click anywhere on a node.

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

      expand_nc (expand no children)
      You can make a node display a plus sign in its folder symbol eventhough it has no child nodes (by setting the EXPANDER field inTREEV_NODE). If the user clicks one of these nodes, the controltriggers the event EXPAND_NC. In the example, the "Program" node hasthis attribute, and the program reacts to the event by adding two newnodes to the control.

      button_click
      The user clicked a pushbutton item.

      link_click
      The user clicked a link item.