‎2008 Feb 04 12:35 PM
Hello Experts,
I need to refresh the ALV TREE.
I have two screens. 1st one has an ALV TREE.
When you click on any of node under the ALV TREE that will open a new modal dialog screen, now I have change some field values on this screen(modal dialog screen).
I want to refresh the ALV TREE based on the data I have changed on Modal dialog screen.
Help me to solve this problem.
Thanks & Regards,
Rock,
‎2008 Feb 04 12:49 PM
Hi,
Assuming that you have used the class "CL_GUI_ALV_TREE", you can use the method "REFRESH_TABLE_DISPLAY" to achieve this functionality. You may do the following:
->Capture the changed values from the modal dialog box.
->Then update/insert these values in the internal table you have used while calling the method "SET_TABLE_FOR_FIRST_DISPLAY".
->Call the method "REFRESH_TABLE_DISPLAY". The tree should automatically reflect the changes.
‎2008 Feb 04 12:52 PM
Hi Rock,
Are you using CL_GUI_ALV_TREE class for your display?
If so, have you tried calling the method FRONTEND_UPDATE, this refreshes the table display when any changes have been made post initialization of tree.
Cheers,
Aditya
‎2008 Feb 04 1:46 PM
Thank you Sharat and Aditya,
Yes, I am using CL_GUI_ALV_TREE class and
FRONTEND_UPDATE , but still result is same.
REFRESH_TABLE_DISPLAY method is private method,
how can I use this method in program???
Is there any other way to do this.....
Thanks & Regards,
Rock,
Edited by: Rock on Feb 4, 2008 7:20 PM
‎2008 Feb 04 10:28 PM
hi,
try this way.
In Alv_tree object if you want to change the content of a field on the screen you can use two different ways:
1- calling the method CHANGE_ITEM for changing the value of a single cell
CALL METHOD g_glob_tree->change_item
EXPORTING
i_node_key = Node_key
i_fieldname = 'FIELD'
i_data = value
i_u_data = 'X'.
CALL METHOD o_alv_tree->frontend_update.
2 - calling the method CHANGE_NODE for changing the line
CALL METHOD o_alv_tree->change_node
EXPORTING
i_node_key = node_key
i_outtab_line = ls_outtab
EXCEPTIONS
node_not_found = 1
OTHERS = 2.
CALL METHOD o_alv_tree->frontend_update.
hope that is useful.
Regards
Marco
‎2008 Feb 05 11:57 AM
Hi
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.
‎2008 Aug 11 10:07 PM