Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Tree-like data structure

0 Kudos

Hi,

I need to update and search data which is organized in a tree like structure, i.e. the data is organized as a parent-child, with a parent able to have 0...M children, and those children able to have 0...M children themselves (i.e. child can have multiple parents), up to a depth of probably 10 or so.

Any child could be selected in the tree, which would necessitate the return the full tree starting from the child up (all parents), and anything below the child if applicable.

1) Could the SAP ALV classes (CL_SIMPLE_TREE_MODEL/CL_LIST_TREE_MODEL/CL_COLUMN_TREE_MODEL) be used for this kind of processing, considering that the tree will not be used to display ALV data. The benefit of using these classes is of course the logic for adding/updating and searching is already there. I just don't know if they are built for this kind of processing.

2) On the subject of data storage, what would be the 'best' data storage format for fastest data retrieval - ddic table(s), cubes? There will be one major initializing update at the start, to populate the parent-child relationships, after which updating relatively small number nodes will happen occasionally but never as frequently as searching. The data store could be broken up by child and/or parent maybe.

Thanks for any insights.

3 REPLIES 3

nomssi
Active Contributor

Hi,

you can then roll your own binary tree implementation in ABAP if you understand list processing (maybe SICT or Algorithms...), cf. ABAP Lisp.

In ABAP we typically use an internal table with deep structure, i.e. the elements (nodes) contain internal tables. I would consider meshes introduced with Netweaver 7.40 SP05.

My answers:

  1. The ALV classes will not help you process the tree.
  2. a tree can be mapped/serialized to a normal database table with a flat structure (e.g. components of a material in table MARA)

Hope this helps,

JNN

horst_keller
Product and Topic Expert
Product and Topic Expert

Jelena
Active Contributor
0 Kudos

What's the business requirement? It might be beneficial to disclose what type of information you're talking about exactly. What you've described looks pretty much like Product Hierarchy functionality (MARA-PRDHA field) in SAP. It has limited depth though. But maybe something to check out for ideas.

Data storage - AFAIK "cubes" is a BI/BW concept. In the core ERP there are only tables. Rather confused by this part... I guess the question is - how exactly will this data be consumed/presented then? And what DB are we talking about?