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
Specifies a hierarchy as a data source in a ABAP SQL query.
- The following can be specified:
- A hierarchy can be specified in the following places:
- As the source of a hierarchy navigator
- As the source of the hierarchy generator
A hierarchy is a tabular set of rows that represent the hierarchy nodes.
- A CDS hierarchy and the hierarchy generator
HIERARCHYcreate their results set from the data source defined for them on the basis of a parent-child relationship itself defined in a hierarchy association.
- A CTE hierarchy represents
the hierarchy (itself specified as the only data source in the subquery of the CTE) under the name of
the CTE in the subsequent queries of the current
The columns of a hierarchy comprise the following:
- Components of the data source used when the hierarchy is created by a CDS hierarchy or created by the hierarchy generator.
- In the case of CDS hierarchies and CTE hierarchies these are precisely the components listed here.
- In the case of the hierarchy generator
HIERARCHY, these are all components of the source of the hierarchy.
- Additional hierarchy columns. For each hierarchy node, the hierarchy columns contain its hierarchy attributes, which describe certain hierarchy-specific properties.
When a hierarchy is used as a data source in a ABAP SQL query, the additional hierarchy columns can be accessed as follows:
- In the
- Hierarchy columns can be specified as regular columns using
colnameand then become part of the results set of the query.
...~*is specified, hierarchy columns are not part of the results set of the query. Only the components of the source of the hierarchy are respected. In this case, the hierarchy columns are also ignored by any structure or internal table created in the
INTOclause by an inline declaration
- In other clauses, hierarchy columns can be specified regardless of the
SELECTlist and are evaluated accordingly.
- It is possible to evaluate the hierarchy columns in a query, but this is not mandatory. In most cases, only the data content of a hierarchy is of interest and not the technical properties of the hierarchy nodes.
The following programs demonstrate the three ways of specifying hierarchies as the data source of a
SELECT statement while reading all possible