ABAP Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Data Definitions → ABAP CDS - DDL for Data Definitions → ABAP CDS - DEFINE HIERARCHY
ABAP CDS - DEFINE HIERARCHY, element_list
Other versions:
7.31 | 7.40 | 7.54
Syntax
... { element1, element2, ..., } ...
Effect
Defines the elements of a CDS hierarchy. The elements are specified in a comma-separated list enclosed in curly brackets { }.
The elements determine either the components of the results set of the CDS hierarchy and of the structured data type represented by the CDS hierarchy with respect to ABAP or they publish a CDS association.
The ABAP data types of the components of the structured data type are derived from the dictionary types of the elements in accordance with the associated mapping rules.
Example
Element list of a CDS hierarchy in which all possible hierarchy attributes are listed after the prefix $node.. The program DEMO_HIERARCHY_TREE_HIER_ATTR accesses the CDS hierarchy and uses ABAP SQL to read all elements of the element list plus the additional hierarchy columns. When executed, the program demonstrates that the values of the hierarchy attributes and of the associated hierarchy columns are the same.
as parent child hierarchy(
source
DEMO_CDS_SIMPLE_TREE_SOURCE
child to parent association _tree
start where
id = 1
siblings order by
id ascending
)
{
id,
parent,
$node.hierarchy_rank as h_rank,
$node.hierarchy_tree_size as h_tree_size,
$node.hierarchy_parent_rank as h_parent_rank,
$node.hierarchy_level as h_level,
$node.hierarchy_is_cycle as h_is_cycle,
$node.hierarchy_is_orphan as h_is_orphan,
$node.node_id as h_node_id,
$node.parent_id as h_parent_id
}