*Author: Naresh Nelapatla* Refreshing the ALV tree display is not actually as simple as it sounds, as there is no actual refresh functionality available. You basically have to delete all the toplevel nodes and then re-add everything as if you are building the hierachy from new Declare table to store top leve nodes in top include types: begin of t_topnodes, nodekey type lvc_nkey, end of t_topnodes. data: it_topnodes type standard table of t_topnodes, wa_topnodes like line of it_topnodes. Add code to build top level node table *&------------------------------------------------------------------* *& Form CREATE_ALVTREE_HIERARCHY *&------------------------------------------------------------------* * text *-------------------------------------------------------------------* * Builds ALV tree display, (inserts nodes, subnodes etc) *-------------------------------------------------------------------* form create_alvtree_hierarchy. data: ls_sflight type sflight, lt_sflight type sflight occurs 0. data: ld_ebeln_key type lvc_nkey, ld_ebelp_key type lvc_nkey. loop at it_ekko into wa_ekko. perform add_ekko_node using wa_ekko '' changing ld_ebeln_key. wa_topnodes-nodekey = ld_ebeln_key. append wa_topnodes to it_topnodes. loop at it_ekpo into wa_ekpo where ebeln eq wa_ekko-ebeln. perform add_ekpo_line using wa_ekpo ld_ebeln_key changing ld_ebelp_key. endloop. endloop. * calculate totals call method gd_tree->update_calculations. * this method must be called to send the data to the frontend call method gd_tree->frontend_update. endform. " CREATE_ALVTREE_HIERARCHY Add code to to the ALV Tree user command functionality ************************************************* * EXAMPLE CODE used for demonstration purpose ** ************************************************* *-------------------------------------------------------------------* * CLASS lcl_toolbar_event_receiver IMPLEMENTATION *-------------------------------------------------------------------* * ........ * *-------------------------------------------------------------------* class lcl_toolbar_event_receiver implementation. method on_function_selected. data: ls_gmsec type zgmsec, ld_answer type c. case fcode. when 'CHNG'. data: ld_uname type zgmuserparam-uname. 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. check not lt_selected_node[] is initial. read table lt_selected_node into l_selected_node index 1. call method tree1->get_outtab_line EXPORTING i_node_key = l_selected_node IMPORTING e_outtab_line = ls_gmsec. if ls_gmsec-uname is initial. message i010(ad) with 'Please choose a valid user'. else. * Example: i.e calls screen to allow user to make chnage call screen 0300. * AT this point user has returned from a screen (i.e. 300) which * allowed them to make changes to existing data/node * The following code deletes all the existing nodes using the top * node table populated earlier loop at it_topnodes into wa_topnodes. call method TREE1->DELETE_SUBTREE EXPORTING i_node_key = wa_topnodes-nodekey. endloop. call method cl_gui_cfw=>flush. * Now you need to re-select your data and re-build your hierarchy * from scratch. for example the code could look somthing like this. REFRESH: it_ekko, it_ekpo. SELECT ebeln UP TO 10 ROWS FROM ekko INTO corresponding fields of TABLE it_ekko. loop at it_ekko into wa_ekko. SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh FROM ekpo appending TABLE it_ekpo where ebeln eq wa_ekko-ebeln. endloop. perform create_alvtree_hierarchy.