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 Control no longer exists" (cl_gui_alv_tree)

0 Kudos

Hi,

in my application I have implemented a tree,which is an instance of cl_gui_alv_tree. In alignment with the MVC pattern I have a view class taking care of the tree object. At first,this view class implemented an interface for specialised ALV tree operations (like 'add_node', 'edit_node', 'checkbox_change' etc.) which itself implemented the general View interface of the application. This one offers very general methods like 'refresh_view', 'initialize_view' etc...

As the class became rather bloated, I decided to decouple the two interfaces and create a ALV tree operations class implementing the aformentioned interface specialised for ALV-Tree operations next to the already existing View class (which held all the ALV tree operations methods which should now be transferred to the newly extracted class) .

For the newly extracted class to still be able to work on the ALV tree object, it needs the reference to the ALV tree object. It receives this reference in the controller which holds references to the general (fomerly bloated) View class (implementing the general view interface) and the newly extracted class for ALV tree operations.

Now comes my problem:
When everything was in the bloated view class, things were working fine, however when working with the ALV tree object in the specialised ALV tree operations class, I get the message 'Tree Control no longer exists' whenever I am executing a tree operation (like expanding a node for instance).

When debugging, I found the reference to the instance is there, everything seems to be set up properly. So I started to debug more precisely and think I found the exact place, where the control gets lost. It happens in the 'QUEUE_TO_CONTROL' method of the Class 'CL_ALV_TREE_BASE' at line 309 when the method 'SET_SCREEN_UPDATE' with the CL_GUI_COLUMN_TREE instance 'MT_COLUMN_TREE' is called. Somehow this is initiating a stack of method calls during which PBO is done and during this I guess the control is completely lost.

I have absolutely no idea, why this happens. When refactoring everything back and working with the bloated class, this method call in line 309 works differently and it does not initiate the same stack of method calls, but instead the next line in the 'QUEUE_TO_CONTROL' method is reached.

I hope, I could somehow make myself clear. If somebody could help me out, that would be great, as I would really love to have the refactoring, I have in mind, work out properly.

1 ACCEPTED SOLUTION

0 Kudos

A night's sleep can make all the difference. I woke up today and immediately saw what's wrong. It is possible for the user to switch between show and change in the application. During this the tree gets rebuild (after the docking container has been freed and a new one instantiated). I simply forgot to update the tree object reference in the newly formed operator class so it was still working with the old reference ( whose control has already been freed at this point, thats why the error message 'Tree control no longer exists').

A rather annoying mistake from my side.

4 REPLIES 4

Sandra_Rossi
Active Contributor

Did you attach your Tree control and its data source to global variables? (otherwise the memory will be deleted and there's no more possible connection with frontend)

0 Kudos

I did. In the general View class the table and the tree object are declared as global class variables and instantiated. Then the Tree operator class receives a reference to this tree instance from the controller.

It should be possible to instantiate the tree object in one class and work on it ( like expanding the node, doing frontend updates) in another, right ?

0 Kudos

A night's sleep can make all the difference. I woke up today and immediately saw what's wrong. It is possible for the user to switch between show and change in the application. During this the tree gets rebuild (after the docking container has been freed and a new one instantiated). I simply forgot to update the tree object reference in the newly formed operator class so it was still working with the old reference ( whose control has already been freed at this point, thats why the error message 'Tree control no longer exists').

A rather annoying mistake from my side.

Florian
Active Contributor

So this is a perfect example that also questions can help to fix it. Would be so kind and put the answer as an answer and close the question.

Pretty sure some others will fall over it too and get that trigger they need.