Ansicht
Dokumentation

ABENCDS_HIERARCHIES - CDS HIERARCHIES

ABENCDS_HIERARCHIES - CDS HIERARCHIES

General Data in Customer Master   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

- Hierarchies

A CDS hierarchy is defined in the DDL source code of a CDS data definition in the ABAP Development Tools using the statement DEFINE HIERARCHY in the CDS DDL of the ABAP Core Data Services (CDS). The name of the CDS hierarchy must match the name of the DDL source code. DDL source code in a CDS hierarchy can also be displayed in Repository Browser in ABAP Workbench.

A CDS hierarchy represents an SQL hierarchy created when the CDS hierarchy is accessed. CDS hierarchies can currently only be used when the standard database is a SAP HANA database. When a CDS hierarchy is activated, a view with the same name is created as an ABAP-managed database object on the database. This view accesses a hierarchy generator function such as HIERARCHY.

A CDS hierarchy is declared as a CDS entity hierarchy using the statement DEFINE HIERARCHY. As a global data type, the CDS entity represents a structured type with the elements of the CDS hierarchy as components and can be used like any CDS entity.

  • In ABAP CDS, the CDS entity can be used as a data source of other CDS entities.
  • In ABAP, the CDS entity can be used as a data type and in read statements.

A CDS hierarchy is located in the namespace of all global types of an AS ABAP.

When using CDS hierarchies, the handling of the special hierarchy attributes is of special importance. These attributes occur as part of the result set of the hierarchy function on the database:

  • The hierarchy attributes can be accessed explicitly as follows:
  • The prefix $node. can be used to list them in the element list of the CDS hierarchy and grant them an alias name. They are then applied like a regular element of the CDS hierarchy.

  • When a query is applied to a CDS hierarchy, they are handled as additional hierarchy columns, regardless of their element list, and their names can be used in explicitly specified columns

This makes it possible to specify a hierarchy attribute in the element list of the CDS hierarchy in two different ways in an query, either by using the name of the element or by using the name of the hierarchy column.
  • When CDS hierarchies are used, the hierarchy attributes are not implicitly considered in the following cases:
  • When used as a data source of other CDS entities.

  • When used as a data type.

  • When used as a data source in , if * or ...~* is specified in the SELECT list.

In these cases, only the explicit elements of the element list are considered. These can, however, represent hierarchy attributes.

Notes

  • 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 supports hierarchies. This requires the constant HIERARCHIES of this class to be passed to the method in an internal table.
  • For a CDS hierarchy, no repository object such as a CDS-managed DDIC view is created in ABAP Dictionary.
  • A hierarchy attribute does not become part of a structured data type created by a CDS hierarchy until it is listed explicitly in the element list of the CDS hierarchy.






Addresses (Business Address Services)   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 6704 Date: 20240420 Time: 010106     sap01-206 ( 79 ms )