Skip to Content

Tree-like data structure

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 02, 2017 at 12:03 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 02, 2017 at 08:21 PM

    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?

    Add comment
    10|10000 characters needed characters exceeded