Ansicht
Dokumentation

ABENSELECT_HIERARCHY_NODE_NAVIS - SELECT HIERARCHY NODE NAVIS

ABENSELECT_HIERARCHY_NODE_NAVIS - SELECT HIERARCHY NODE NAVIS

Vendor Master (General Section)   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.
SAP E-Book

SELECT, FROM hierarchy_node_navigator

... ${HIERARCHY_DESCENDANTS
    $|HIERARCHY_ANCESTORS
    $|HIERARCHY_SIBLINGS$}(
       SOURCE hierarchy
       START WHERE sql_cond
      $[DISTANCE $[FROM n1$] $[TO n2$]$] ) ...


Variants:

1. HIERARCHY_DESCENDANTS( ... )

2. HIERARCHY_ANCESTORS( ... )

3. HIERARCHY_SIBLINGS( ... )

Addition:

... DISTANCE $[FROM n1$] $[TO n2$]

Effect

Specifies a hierarchy node navigator as a data source data_source in an query. It accesses and evaluates the SQL hierarchy hierarchy specified after SOURCE.

After START WHERE, a logical expression sql_cond must be specified that contains conditions for hierarchy nodes of the SQL hierarchy after SOURCE. The columns of the hierarchy can also be used as operands here. Any hierarchy nodes that meet the conditions are the start nodes of the hierarchy navigators. They evaluate the SQL hierarchy hierarchy specified after SOURCE, starting from all start nodes, and insert the selected hierarchy nodes into their result set.

In addition to the hierarchy columns of the SQL hierarchy specified after SOURCE, the result set of each of these hierarchy navigators contains two further hierarchy columns:

  • START_RANK with the type INT8
  • START_ID with the type SSTRING and length 1333

In each row of the result set, these columns contain the values of the hierarchy columns HIERARCHY_RANK and NODE_ID of the associated start nodes.

Variant 1

HIERARCHY_DESCENDANTS( ... )


Effect

The hierarchy navigator HIERARCHY_DESCENDANTS selects all descendant nodes of the start nodes and the start nodes themselves, from the SQL hierarchy hierarchy specified after SOURCE. In addition the hierarchy columns of the SQL hierarchy specified after SOURCE, plus START_RANK and START_ID, the result set contains a further hierarchy column, HIERARCHY_DISTANCE, with the type INT4, which contains the distance to the respective start node. This distance is the positive difference between the hierarchy levels HIERARCHY_LEVEL of the individual child nodes and the respective start nodes.

Example

Call of the hierarchy navigator HIERARCHY_DESCENDANTS in the program DEMO_HIERARCHY_NAVIGATORS, where the hierarchy generator HIERARCHY is specified as the source. When executed, this program demonstrates how this hierarchy navigator works. It also displays the value of the hierarchy column HIERARCHY_DISTANCE.

Variant 2

HIERARCHY_ANCESTORS( ... )


Effect

The hierarchy navigator HIERARCHY_ANCESTORS selects all ancestor nodes of the start nodes, as well as the start nodes themselves, from the SQL hierarchy specified after SOURCE. In addition to the hierarchy columns of the SQL hierarchy specified after SOURCE, plus START_RANK and START_ID, the result set contains a further hierarchy column, HIERARCHY_DISTANCE, with the type INT4, which contains the distance to the respective start node. This distance is the negative difference between the hierarchy levels HIERARCHY_LEVEL of the individual parent nodes and the respective start nodes.

Example

Call of the hierarchy navigator HIERARCHY_ANCESTORS in the program DEMO_HIERARCHY_NAVIGATORS, where the CDS hierarchy DEMO_CDS_SIMPLE_TREE is specified as a source. When executed, this program demonstrates how this hierarchy navigator works. It also displays the value of the additional hierarchy column HIERARCHY_DISTANCE.

Variant 3

HIERARCHY_SIBLINGS( ... )


Effect

The hierarchy navigator HIERARCHY_SIBLINGS selects all sibling nodes of the start nodes, as well as the start nodes themselves, from the SQL hierarchy specified after SOURCE. In addition to the hierarchy columns of the SQL hierarchy specified after SOURCE, plus START_RANK and START_ID, the result set contains a further hierarchy column, HIERARCHY_SIBLING_DISTANCE, with the type INT4, which contains the distance to the respective start node. This is the positive or negative difference between the numbers HIERARCHY_RANK of the sibling nodes and the respective start nodes.

Note

If the values in the additional column HIERARCHY_SIBLING_DISTANCE are accessed, the addition SIBLINGS ORDER BY should be used in the SQL hierarchy specified after SOURCE. Otherwise, the values remain undefined.

Example

Call of the hierarchy navigator HIERARCHY_SIBLINGS in the program DEMO_HIERARCHY_NAVIGATORS, where the CTE hierarchy +hierarchy is specified a source. When executed, this program demonstrates how this hierarchy navigator works. It also displays the value of the additional hierarchy column HIERARCHY_SIBLING_DISTANCE.

Addition

... DISTANCE $[FROM n1$] $[TO n2$]

Effect

In the case of the hierarchy navigators HIERARCHY_DESCENDANTS and HIERARCHY_ANCESTORS, the addition DISTANCE restricts the distance to the respective start node. The addition DISTANCE cannot be specified for the hierarchy navigator HIERARCHY_SIBLINGS.

At least one of the additions FROM or TO must be specified in the order shown. n1 and n2 expect host variables, host expressions, or literals with the type i. Only the types b, s, or i can be used. Only those hierarchy nodes are selected for which the value of the hierarchy column HIERARCHY_DISTANCE is between the values of n1 and n2. If the value of n1 is greater than n2, no hierarchy node is selected. If TO, is not specified, there is no upper limit. If FROM, is not specified, there is no lower limit.

Notes

  • The function of the addition DISTANCE can also be achieved using the comparison operator BETWEEN for the hierarchy column HIERARCHY_DISTANCE. In this case, the selection is applied to the result set of the hierarchy navigator rather than being performed by the navigator itself.
  • To get hierarchy nodes in the result set of HIERARCHY_DESCENDANTS, the interval boundaries must include positive values. To get hierarchy nodes in the result set of HIERARCHY_ANCESTORS, the interval boundaries must include negative values.
  • To exclude the start nodes from the result set, the additions FROM and TO can be used as follows:
  • If FROM 1 is specified without the addition TO, HIERARCHY_DESCENDANTS selects only descendant nodes

  • If TO -1 is specified without the addition FROM, HIERARCHY_ANCESTORS selects only the ancestor nodes

Example

Call of the hierarchy navigator HIERARCHY_DESCENDANTS in the program DEMO_HIERARCHY_DISTANCE while specifying the addition DISTANCE. When executed, this program demonstrates how this addition works. If, for example, the value 2 is specified for n1 and 3 is specified for n2, only the grandchildren nodes and great-grandchildren nodes of the start node are selected. If -3 is specified for n1 and -2 is specified for n2, the result set of HIERARCHY_DESCENDANTS is empty. For these values, on the other hand, the result set of HIERARCHY_ANCESTORS contains the grandparents and great-grandparents of the start node.






ABAP Short Reference   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 12891 Date: 20240416 Time: 161150     sap01-206 ( 193 ms )