Skip to Content
0

ALV tree with Dynamic child nodes

Jun 09, 2017 at 06:28 AM

487

avatar image
Former Member

Hello Experts,

Have a requirement to build a tree structure with child nodes and on clicking or double clicking of child nodes - on the right side of the screen Editable ALV to load where the user can enter details and save to custom table.

I was able to do a proto using Simple ALV tree cl_gui_simple_tree as shown below.

alv-tree.jpg

Now the problem arises when the Child nodes are to be dynamic - Simple ALV as per my understanding does not allow this - as the NodeKey structure is fixed.... thats where i am struck.

Explored BCALV programs and SDN - tried using cl_gui_alv_tree - but this requires output table to provided and which display the columns - does not fit what i am looking for.

We need the child nodes to displayed and only on double click require ALV to be loaded with variable columns....

Simple ALV seems to suit perfect - provided it can be made dynamic nodes ... any trick or tips to make this work. Please suggest or any sample program or reference would greatly help.

alv-tree.jpg (101.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Sandra Rossi Jun 10, 2017 at 12:46 PM
0

If you are using CL_GUI_ALV_TREE_SIMPLE, then you can't add new nodes after having used SET_TABLE_FOR_FIRST_DISPLAY. Instead, you may use CL_GUI_ALV_TREE, which provides the method ADD_NODE.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Yes right, but the issue with CL_GUI_ALV_TRE ->ADD_NODE is - we have to provide the output table structure at the time of adding the node - which will not suit my requirement.

I want something similar to SE80 - where you have dynamic nodes builded based on the program and then when you double click on a program - instead of Editor - i am planning to use ALV grid to display the fields (which will vary from node to node).

If you look at the screen shot i gave - the nodes are to be dynamic and on double click - require an editable ALV grid with varying fields... is this even possible? thanks

0

Yes, it's possible.

If you want additional columns in the tree, i.e. not only the "hierarchy column" but also additional columns at the right of this column, you can do it with CL_GUI_ALV_TREE. But if you don't need the ALV features, you may also use either CL_GUI_COLUMN_TREE or CL_COLUMN_TREE_MODEL. All three classes are using the same OCX control, so they have basically the same features and look like the same (only the class themselves restrict some of the control features, like CL_GUI_ALV_TREE_SIMPLE which doesn't allow adding nodes).

If you prefer to display only a single text at each line (as you show in pictures), then you may use CL_GUI_SIMPLE_TREE or CL_SIMPLE_TREE_MODEL (both are based on an OCX control which is different from the OCX control for column trees). You can run the demo program SAPSIMPLE_TREE_CONTROL_DEMO.

The double click feature is available for all trees. Displaying an ALV grid is possible, and do whatever you want too.

Please look at the links provided by Raymond above.

0
Richard Harper Jun 09, 2017 at 08:02 AM
0

I may not be following you correctly, but writing a wrapper around the cl_gui_Alv_Grid object that accepts a field catalog and a memory reference to a dynamically created work area and table seems to be quite easy to me. So, when you build your alv tree have a non displayable field which is a table of column names and their definitions (or the name of a DDic structure), and when the node is clicked create thE table using CREATE DATA, populate the table and get a memory reference to it. Pass that and the field catalog to your wrapper and then construct the ALV from that.

You can also include things like the alv grid title etc etc as parameters or even the name of a global class which encapsulates the alv grid object so that you can handle data in different ways..

Rich

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi rich, thanks for the suggestion. I dont have issue in alv grid...the problem is with alv tree class. When using simple alv tree...to add child nodes, we have to use addnodes method, which build the child nodes.

This structure have nodes(fields) as fixed, so i would need to know my nodes before creating this structure, as its fixed number to nodes.

But i require ALV tree with dynamic nodes, so that it can grow as required.

Can this be achieved with simple alv.

Thanks

0

What I am suggesting is to have two additional non displayed fields on the tree table row. This would contain a field cayalog and the second will have an internal table with the relevant records in it.

I obviously don't follow what your on about with the nodes - I have no problem adding extra nodes to tree. There is no fixed number - each node is a structure not a distinct field in the structure

1
Raymond Giuseppi
Jun 09, 2017 at 08:24 AM
0

Which of the avalable tree classes did you already try (Overview of SAP Tree Classes), did you check for samples)

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jun 19, 2017 at 04:34 AM
0

thanks all i am able to display varying nodes using Simple ALV tree and split container to display the ALV grid. works fine. thanks a lot for all your help and suggestions.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

why now does it work, please? (initial question: "I was able to do a proto using Simple ALV tree [...] Now the problem arises when the Child nodes are to be dynamic")

1
Former Member

Hi Sandra, its working now - as we made few changes to requirement and the development as well... firstly now we have arrived a tree at the time of initiating the tree object - hence the simple tree is able to do it...

also have now used docking container for tree object and the other half of the screen have used custom container in a screen to display ALV object -which will change as per the double click event on tree nodes...

thanks again.

0