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: 

Refresh nodes of alv tree

Former Member
0 Kudos

I am trying to refresh an alv tree. I want certain nodes hidden/removed based on what the user selects. So far I have to free my tree and start over and rebuild the nodes. I was wondering if there is a way to just refresh the nodes to display the desired nodes.

I have tried:

call method tree->delete_all_nodes.

then call my process to add the desired nodes.

CALL METHOD tree->frontend_update.

I found the problem when expanding all nodes that a node key is unable to expand. I found that the attribute M_NODE_KEY_COUNT of CL_ALV_TREE_BASE wasn't reset when all the nodes where deleted so it keeps accumulating to the total nodes created when I originally created the tree.

Anybody know how to do this without freeing the tree and starting over.

Thanks.

Brent

3 REPLIES 3

Former Member
0 Kudos

I have the excact same problem.

Did you find a workaround or a solution Brent?

Former Member
0 Kudos

Hi Brent,

Previously I have a requiremnt to delete some of the nodes from the tree. I have done that it is working for me. But here I am using CL_GUI_ALV_TREE class.

See the code below.

WHEN 'DELETE'.

  • get selected node

DATA: LT_SELECTED_NODE TYPE LVC_T_NKEY.

CALL METHOD TREE1->GET_SELECTED_NODES

CHANGING

CT_SELECTED_NODES = LT_SELECTED_NODE.

CALL METHOD CL_GUI_CFW=>FLUSH.

DATA L_SELECTED_NODE TYPE LVC_NKEY.

READ TABLE LT_SELECTED_NODE INTO L_SELECTED_NODE INDEX 1.

  • delete subtree

IF NOT L_SELECTED_NODE IS INITIAL.

CALL METHOD TREE1->DELETE_SUBTREE

EXPORTING

I_NODE_KEY = L_SELECTED_NODE

I_UPDATE_PARENTS_EXPANDER = ''

I_UPDATE_PARENTS_FOLDER = 'X'.

ELSE.

MESSAGE I227(0H).

ENDIF.

  • update frontend

CALL METHOD TREE1->FRONTEND_UPDATE.

It is working for me. Hope this will help you.

Thanks & Regards,

Siri.

Message was edited by: Srilatha T

Message was edited by: Srilatha T

Former Member
0 Kudos

Ive been looking thru the code of CL_ALV_TREE_BASE and found that the only place that M_NODE_KEY_COUNT is used is in ADD_NODE where it is incremented by 1. The only time it is set to 1 is when creating a tree object.

This leads me to think that the developers of the cl_gui_alv_tree has forgotten to reset this value. This may be a candidate for an OSS then.

Anders