Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Reads →  SELECT clauses →  SELECT - FROM →  SELECT - FROM data_source →  SELECT - FROM hierarchy_data →  SELECT - FROM hierarchy 

Hierarchy Columns

Hierarchy columns are additional components of the results set when the following data sources are accessed in a ABAP SQL query:

The hierarchy columns have the same names and contain the values of the hierarchy attributes of the data sources above. Using these, they provide information about the hierarchy node in question. The following table shows the name and meaning of each hierarchy column:

Name Data Type Meaning
HIERARCHY_RANK INT8 Sequential number granted as a unique hierarchy node ID when a hierarchy is created.
HIERARCHY_TREE_SIZE INT8 Number of descendant nodes of the hierarchy node (including the hierarchy node itself).
HIERARCHY_PARENT_RANK INT8 0 for root nodes, else the HIERARCHY_RANK ID of theparent node.
HIERARCHY_LEVEL INT4 Hierarchy level of the hierarchy node. Always 1 forroot nodes. For theirdescendant nodes, the distance from the root node plus one.
HIERARCHY_IS_CYCLE INT1 Flag indicating whether the hierarchy node is part of (1) or is not part of (0) a node cycle.
HIERARCHY_IS_ORPHAN INT1 Flag indicating whether the hierarchy node is (1) or is not (0) an orphan node.
NODE_ID SSTRING, length 1333 Internal character-like key of the hierarchy node that chains the values of all target data source fields of the associatedhierarchy associationspecified in the ON conditions. If there is only one comparison in theON condition, no chaining is required and the data type is the data type of the specified field of the target data source.
PARENT_ID SSTRING, length 1333 Internal character-like key of the hierarchy node that chains the values of all source data source fields of the associatedhierarchy associationspecified in the ON conditions. If there is only one comparison in theON condition, no chaining is required and the data type is the data type of the specified field of the source data source.
VALID_FROM, VALID_UNTIL
DATS, TIMESTAMP, TIMESTAMPL This attribute exists only for temporal hierarchies. The contain the limits of thevalidity interval of the currenthierarchy node of atemporal hierarchy.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • Alongside the general hierarchy columns shown here, the hierarchy navigators might also have several special columns.

  • The hierarchy columns must be specified explicitly in the SELECT list before they can be selected.

  • The values of some hierarchy columns are usable only if the hierarchy is a tree-like hierarchy in which a hierarchy node does not have multiple parent nodes.

Example

Accesses the hierarchy columns explicitly when a CDS hierarchy is specified as a data source in a SELECT statement in the program DEMO_HIERARCHY_PARENT_CHILD.

DATA(start_id) = 'A '. 

SELECT FROM demo_cds_parent_child( p_id = @start_id ) 
       FIELDS id, 
              parent, 
              hierarchy_rank, 
              hierarchy_tree_size, 
              hierarchy_parent_rank, 
              hierarchy_level, 
              hierarchy_is_cycle, 
              hierarchy_is_orphan, 
              node_id, 
              parent_id 
       INTO TABLE @DATA(cds_result).