Tree

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

Properties tab:

Item «Value»

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-area 1 occupies the left-top cell of the area.

  • Sub-area 2 occupies the second cell from the left (and the rest cells are righter, if available) of the topmost row of the area.

  • Sub-area 3 occupies the second cell from the top (and other cells below, if available) in the leftmost column of the area.

  • Sub-area 4 occupies other cells of the area.

Why the marking up is required? First you need to understand that:

  • Sub-areas 1 and 2 specifies formatting of the tree header (the row, that displays the column names).

  • Sub-areas 3 and 4 specifies formatting of the data rows. Herewith, sub-area 3 specifies formatting of the hierarchy column (the column with tree nodes); sub-area 4 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-area 3 and 4. The 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-area 2 and 4. The 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 buttons

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 (markers:

appear 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-areas 1 and 2.


  • Hierarchy column

If this option is enabled, the column with nodes will be displayed.

Note: regardless of this option the markup must contain sub-areas 1 and 3.

      • Switching between options:

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-areas 2 and 3.


    • 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.