define view Z_VBFA
as select from vbfa
association [0..1] to Z_VBFA as _Recursion on $projection.PrecedingDocument = _Recursion.SubsequentDocument
and $projection.PrecedingItem = _Recursion.SubsequentItem
{
key vbelv as PrecedingDocument,
key posnv as PrecedingItem,
vbeln as SubsequentDocument,
posnn as SubsequentItem,
vbtyp_n as SubsequentDocCategory,
_Recursion
}
where
vbtyp_n = 'C'
@Hierarchy.parentChild: [ { name: 'Recursion', recurseBy: '_Recursion' } ]
@Hierarchy.parentChild: { name: 'Recursion',
recurse : { parent: ['PrecedingDocument','PrecedingItem'], child ['SubsequentDocument','SubsequentItem'] }
}
define hierarchy Z_VBFA_HIERARCHY
as parent child hierarchy (
source Z_VBFA
child to parent association _Recursion
siblings order by PrecedingDocument ascending, PrecedingItem ascending
orphans root
)
{
key PrecedingDocument,
key PrecedingItem,
SubsequentDocument,
SubsequentItem,
$node.parent_id as ParentNode,
$node.node_id as ChildNode,
$node.hierarchy_is_orphan as HierarchyIsOrphan,
$node.hierarchy_level as HierarchyLevel,
$node.hierarchy_rank as HierarchyRank,
$node.hierarchy_parent_rank as HierarchyParentRank,
$node.hierarchy_tree_size as HierarchyTreeSize
}
SELECT parent_id AS parent,
node_id AS node,
hierarchy_level AS level,
hierarchy_rank AS rank,
hierarchy_tree_size AS tree_size
FROM HIERARCHY( SOURCE z_vbfa
CHILD TO PARENT ASSOCIATION _recursion
START WHERE precedingdocument = '0000000024' AND precedingitem = '000000'
SIBLINGS ORDER BY precedingdocument ASCENDING, precedingitem ASCENDING )
INTO TABLE @DATA(lt_hierarchy).
INDEX | PARENT | NODE | LEVEL | RANK | TREE_SIZE |
1 | 10,0000000024;6,000000 | 10,0000000025;6,000000 | 1 | 1 | 11 |
2 | 10,0000000025;6,000000 | 10,0000000067;6,000000 | 2 | 2 | 1 |
3 | 10,0000000025;6,000000 | 10,0000000061;6,000000 | 2 | 3 | 1 |
4 | 10,0000000025;6,000000 | 10,0000000060;6,000000 | 2 | 4 | 1 |
5 | 10,0000000025;6,000000 | 10,0000000063;6,000000 | 2 | 5 | 1 |
6 | 10,0000000025;6,000000 | 10,0000000064;6,000000 | 2 | 6 | 1 |
7 | 10,0000000025;6,000000 | 10,0000000065;6,000000 | 2 | 7 | 1 |
8 | 10,0000000025;6,000000 | 10,0000000066;6,000000 | 2 | 8 | 1 |
9 | 10,0000000025;6,000000 | 10,0000000068;6,000000 | 2 | 9 | 3 |
10 | 10,0000000068;6,000000 | 10,0000000069;6,000000 | 3 | 10 | 1 |
11 | 10,0000000068;6,000000 | 10,0000000070;6,000000 | 3 | 11 | 1 |
SELECT *
FROM HIERARCHY_DESCENDANTS( SOURCE z_vbfa_hierarchy
START WHERE precedingdocument = '0000000024'
AND precedingitem = '000000' )
INTO TABLE @DATA(lt_descendants).
INDEX | PRECEDING DOCUMENT | PRECEDING ITEM | SUBSEQUENT DOCUMENT | SUBSEQUENT ITEM | PARENT NODE | CHILD NODE | HIERARCHY ISORPHAN | HIERARCHY LEVEL | HIERARCHY RANK | HIERARCHY PARENTRANK | HIERARCHY TREESIZE |
1 | 0000000024 | 0 | 0000000025 | 0 | 10,0000000024;6,000000 | 10,0000000025;6,000000 | 1 | 1 | 2 | 0 | 11 |
2 | 0000000025 | 0 | 0000000067 | 0 | 10,0000000025;6,000000 | 10,0000000067;6,000000 | 1 | 2 | 3 | 2 | 1 |
3 | 0000000025 | 0 | 0000000061 | 0 | 10,0000000025;6,000000 | 10,0000000061;6,000000 | 1 | 2 | 4 | 2 | 1 |
4 | 0000000025 | 0 | 0000000060 | 0 | 10,0000000025;6,000000 | 10,0000000060;6,000000 | 1 | 2 | 5 | 2 | 1 |
5 | 0000000025 | 0 | 0000000063 | 0 | 10,0000000025;6,000000 | 10,0000000063;6,000000 | 1 | 2 | 6 | 2 | 1 |
6 | 0000000025 | 0 | 0000000064 | 0 | 10,0000000025;6,000000 | 10,0000000064;6,000000 | 1 | 2 | 7 | 2 | 1 |
7 | 0000000025 | 0 | 0000000065 | 0 | 10,0000000025;6,000000 | 10,0000000065;6,000000 | 1 | 2 | 8 | 2 | 1 |
8 | 0000000025 | 0 | 0000000066 | 0 | 10,0000000025;6,000000 | 10,0000000066;6,000000 | 1 | 2 | 9 | 2 | 1 |
9 | 0000000025 | 0 | 0000000068 | 0 | 10,0000000025;6,000000 | 10,0000000068;6,000000 | 1 | 2 | 10 | 2 | 3 |
10 | 0000000068 | 0 | 0000000069 | 0 | 10,0000000068;6,000000 | 10,0000000069;6,000000 | 1 | 3 | 11 | 10 | 1 |
11 | 0000000068 | 0 | 0000000070 | 0 | 10,0000000068;6,000000 | 10,0000000070;6,000000 | 1 | 3 | 12 | 10 | 1 |
SELECT *
FROM HIERARCHY_ANCESTORS( SOURCE z_vbfa_hierarchy
START WHERE precedingdocument = '0000000024'
AND precedingitem = '000000' )
INTO TABLE @DATA(lt_ancestors).
INDEX | PRECEDING DOCUMENT | PRECEDING ITEM | SUBSEQUENT DOCUMENT | SUBSEQUENT ITEM | PARENTNODE | CHILDNODE | HIERARCHY ISORPHAN | HIERARCHY LEVEL | HIERARCHY RANK | HIERARCHY PARENTRANK | HIERARCHY TREESIZE |
1 | 0000000024 | 0 | 0000000025 | 0 | 10,0000000024;6,000000 | 10,0000000025;6,000000 | 1 | 1 | 2 | 0 | 11 |
SELECT
FROM HIERARCHY_DESCENDANTS( SOURCE HIERARCHY( SOURCE z_vbfa
CHILD TO PARENT ASSOCIATION _recursion
START WHERE precedingdocument = '0000000024'
AND precedingitem = '000000'
SIBLINGS ORDER BY precedingdocument ASCENDING, precedingitem ASCENDING )
START WHERE precedingdocument = '0000000024' AND precedingitem = '000000' )
FIELDS node_id,
parent_id,
hierarchy_rank,
hierarchy_level,
hierarchy_tree_size,
hierarchy_distance
INTO TABLE @DATA(lt_descendants_2).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |