Tree

«Tree» – is a component for exporting ALV TREE from printing program to the form.




Properties tab: 

As value you can use a class instance : CL_SALV_TREE or CL_HRPAYNA_GUI_ALV_TREE (for CL_GUI_ALV_TREE exporting).

Of course, the class instance can be used as whole context, or as one of the components which nested in the context.

Note: 
The class CL_HRPAYNA_GUI_ALV_TREE inherits all the properties/methods/events of the class CL_GUI_ALV_TREE. 
Using of cubclass insted the original CL_GUI_ALV_TREE is due to a technical necessity (the presence of an additional method GET_OUTTAB to getting a table structure ) 


Item «Area in the template»

First, go to Excel menu: Data > Outline and uncheck the checkboxes in the popup-window (if they are checked):


Tree formatting is described by the markup of related area in the Excel template . 

The area must be marked up according the rules described below.

  • The area has at least two horizontal cells and two vertical ones (there may be a greater than 2 cells in any of the directions). The area is divided into four sub-areas, which in the figure marked with white numbers in red circles, and their boundaries are marked with a red dashed line
  • Sub-areaoccupies the left-top cell of the area. 
  • Sub-areaoccupies the second cell from the left (and the rest cells are righter, if available) of the topmost row of the area
  • Sub-areaoccupies the second cell from the top (and other cells below, if available) in the leftmost column of the area.
  • Sub-areaoccupies other cells of the area.


Why the marking up is required? First you need to understand that:
  • Sub-areas  and  specifies formatting of the tree header (the row, that displays the column names)
  • Sub-areas  and  specifies formatting of the data rowsHerewith, sub-area  specifies formatting of the hierarchy column (the column with tree nodes); sub-area  specifies formatting of the other columns (output table columns). 

The figure below illustrates all of the above :



OK. However, in the ALV-TREE hierarchy levels have different colors. How to do same in Excel?

It is possible to control the color and other cell formatting options (text: font/size/color etc.)  for each level of the hierarchy.
To do this, you need to add more rows to the sub-areaandThe principle is: each row below (in the markup) describes the formatting of the next hierarchy level of tree (for example, the second row describes the second hierarchy level, the third row - the third level, etc.). 
Herewith, the formatting of the last row (of the markup) applies to the corresponding hierarchy level (of the tree) and the following (more deep) hierarchy levels too, if they available. For example, if the last row (of the markup) is third, it describes the third hierarchy level (of the tree), and 4, 5, 6, etc.:




Well, if we want to colorize the columns in a different colors?

It is possible to control the color and other cell formatting options (text: font/size/color etc.) for each column .
To do this, you need to add more columns to the sub-areaandThe principle is: each column (in the markup) describes the formatting of the corresponding tree column. Herewith, the formatting of the rightmost column (of the markup area) applies to the corresponding tree column and the following columns too, if they available.

It the figure below, we need to colorize ObjectID column to the green gradient, but the address fields (are placed righter then ObjectID) we need to colorize to the gray gradient. To do this, you only need to add formatting the first of the "address" tree columns, because this formatting will spread to the rest "address" columns (they are all placed righter):





 

Item «Output direction»

The item defines the tree positioning relative to the previous component
(to change output direction you have to press the button 
/ ). This option described in detail in «Pattern» component.

 


Item «Layout options»

The item contains tree layout options.

  • Orientation

        The option has two states
    •  - tree is displayed in the normal state - with a vertical hierarchy. 

    •  - tree rotated 90 degrees counterclockwise - the hierarchy becomes horizontal. In this case, marking up will be different:

  • Structure

        If this option is enabled, the hierarchy levels becomes grouped (marker  or  appears  near each node which has child nodes). Moreover, it is possible to choose the initial state of the nodes in the Excel:
    •  - all nodes are expanded.
    •  - all nodes are collapsed.
    •  - each node has a state respecting the actual node state in the ALV TREE. 

  • Header 

        If this option is enabled, the row that displays the column names appears in the tree. 
        Note: regardless of this option the markup must contain sub-areasand. 

  • Hierarchy column 

        If this option is enabled, the column with nodes will be displayed. 
        Note: regardless of this option the markup must contain sub-areasand. 
    • Switch  <-->  allows you to select whether the hierarchy column displayed before output table columns, or after them.
    • Option  specifies the offset of the node text for each of the next hierarchy level with respect to the previous one. Offset is achieved by adding a certain number of spaces at the beginning of the node text. The offsets option can be disabled by setting the value to 0.
       

  • Other columns 

        If this option is enabled, the output table columns will be displayed
        Note: regardless of this option the markup must contain sub-areasand. 

    • Width from fieldcatalog. 
      • If this option is enabled, width of the tree columns will be taken from actual fieldcatalog of the ALV-Tree (field OUTPUTLEN)Herewith, you are prompted to specify a multiplier by which you can fine-tune width of the column.
      • If this option is disabled, width of the tree columns will be taken from corresponding columns of the Excel-template.
    • Allow formulas.
      • If this option is enabled, all values, which beginning with '=' , will be interpreted as formula ( See more details here ).
      • If this option is disabled, values will be inserted to the cell regular way.