Web Dynpro – Creating a Table Tree

Home / SAP / ABAP Web Dynpro / Web Dynpro – Creating a Table Tree

I have to say, this turned out to be a lot easier than I originally expected.  I recently did a post where I talked about this.  Well, I was about to make things a lot harder than I needed to.  I thought I had to do the NST (nested) version of the table tree, but it turns out, I didn’t need to.  So today, I’ll walk you through just how easy it is to create a table tree for your ABAP Web Dynpro application.

Now, the first really cool thing is that you need a fancy new structure.  You can convert any existing table into a table tree.  It’s just a new column that you add.  This made life much easier (of course I found new ways to complicate it.  ha ha ha).  So now, what do you need to do…

First, you need a context node and some attributes.  Here’s a run down of what you need:

Then we will create attributes required for the tree column. We require 5 attributes

  1. Attribute which contains the current level of the node. Create an attribute called “NODE_LEVEL” of type STRING.
  2. Attribute which contains the parent level of the node. Create an attribute called “PARENT_LEVEL” of type STRING.
  3. Attribute which contains X or Space depending upon the node is expanded or not. Create an attribute called “EXPANDED” of type WDY_BOOLEAN.
  4. Attribute which contains X or Space depending upon the type of the node, whether the node is a branch or a leaf. Create an attribute called “IS_LEAF” of type WDY_BOOLEAN.
  5. Then whatever else you want in your table.  None of these columns need to show up in your table, but you need them in the context.

Now you create a table, and link this context node to it.  I like using the wizard to create all my columns, but create it any way you like.  Now, create a new column, but this time it’s a special column.  Use the menu: Insert Master Column.  This is where all the power is.  The element inside should of type: TreeByKeyTableColumn (use the NST version if you want to calculate the lower nodes as you click on the table).  I was already calculating the full structure, so I didn’t need to go down this path.
Once the column exists, you need to bind several elements:
Expanded -> Expanded
Is_leaf     -> Is_leaf.
Parent_key -> Parent_level
Row_key   -> Node_level

Now, the big thing to remember is that the Parent_Key & Row_key are the direct link to make the tree work.  If you leave parent_key blank, this will be shown as the top level.  In my example, I had multiple values with blank parent.  From there, you just need to make sure that each sub level has a row key, and a parent key that matches one of the levels above it.

From there, just make sure you bind all the table entries into the context, and you magically have a table tree.

I’m pretty excited about this one.  It was easy, and looks very cool.  Now, onto my follow on functionality (there’s always something new).  Who knows, it might even give me an idea for another post :).

Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,

Leave a Reply

Your email address will not be published. Required fields are marked *