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: 

How to refresh data in ALV TREE

Former Member
0 Kudos

Hi,

I need to refresh data of an ALV TREE.

I update data in execution but I can't refresh the ALV TREE.

Any suggest?

Thanks

Salvatore

1 ACCEPTED SOLUTION

Former Member

i think my code works fine. Refreshing the ALV tree display is not actually as simple as it sounds, as there is no

actual refresh functionality available.

keep rocking ... \m/

6 REPLIES 6

Former Member
0 Kudos

Delete all the toplevel nodes and then

re-add everything as if you are building the hierachy from new.

1st 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.

Then 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

next step

Add code to to the ALV Tree user command functionality

  • EXAMPLE CODE *

*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.

Former Member
0 Kudos

hope this code helps u

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.

Former Member
0 Kudos

use the function module

refresh_alv_list_display.

Former Member
0 Kudos

HI EXPERT,

TO REFRESH ALV TREE CHECK THE FOLLOWING CODE..

I DID IT ..

REALLY ITS WORKING ..

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.

I KNOW I WILL GET POINTS BUT THAN ELSE...

PLZ REWARD POINTS IF USEFUL TO U ..

REGARDS,.

BHUMIT MEHTA

Former Member

i think my code works fine. Refreshing the ALV tree display is not actually as simple as it sounds, as there is no

actual refresh functionality available.

keep rocking ... \m/

Former Member
0 Kudos

I'm using CL_GUI_LIST_TREE class.

I'm tryng to delete and then re-add all nodes but the ALV Tree doesn't change.

Let me give you a simple example:

I want to hide and shoe th ALV using a button.

If I set the tree visible or not visible anything changes....