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

Other versions: 7.31 | 7.40 | 7.54

Syntax


... hierarchy 
  | hierarchy_navigator ...

Effect

Specifies hierarchy data as a data source data_source in a ABAP SQL query. Possible hierarchy data is:

Access to hierarchy data is not supported by all databases.


Notes

  • Hierarchy data sources are handled like any other data source. They can have alias names defined using AS and can be used in join expressions. There are no restrictions on which queries they can be used in.

  • In an ABAP program, it is possible to use the method USE_FEATURES of the class CL_ABAP_DBFEATURES to check whether the current database system or a database system accessed using a secondary connection supports access to hierarchy data. This requires the constant HIERARCHIES of this class to be passed to the method in an internal table.

Example

Accesses the hierarchy navigator HIERARCHY_SIBLINGS as the data source of a query. The hierarchy navigator uses a CDS hierarchy as a source.

DATA(id) = 5. 

SELECT FROM HIERARCHY_SIBLINGS( 
              SOURCE demo_cds_simple_tree( p_id = 1 ) 
              START WHERE id = @id ) 
       FIELDS id, 
              parent_id, 
              hierarchy_rank, 
              hierarchy_level, 
              hierarchy_tree_size, 
              hierarchy_sibling_distance 
       INTO TABLE @DATA(ancestors).

Continue

SELECT - FROM hierarchy

SELECT - FROM hierarchy_navigator