‎2007 Mar 19 11:37 AM
Hi experts, I have a problem with a ALV tree. When I execute the report i cant see nothing, th tree is empty and no data appears.
can you help me??
‎2007 Mar 19 12:22 PM
hi,
did u use it?
data:G_TREE TYPE REF TO CL_GUI_LIST_TREE.
CALL METHOD G_TREE->ADD_NODES_AND_ITEMS
EXPORTING
NODE_TABLE = NODE_TABLE
ITEM_TABLE = ITEM_TABLE
ITEM_TABLE_STRUCTURE_NAME = 'MTREEITM'
EXCEPTIONS
FAILED = 1
CNTL_SYSTEM_ERROR = 3
ERROR_IN_TABLES = 4
DP_ERROR = 5
TABLE_STRUCTURE_NAME_NOT_FOUND = 6.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
regards,
bharat.
‎2007 Mar 19 11:40 AM
Hi,
Have u called method SET_TABLE_FOR_FIRST_DISPLAY
Hope this helps
Regds,
Seema
‎2007 Mar 19 11:41 AM
Yes I called this method but nothing appears, neither th title of th repot.
‎2007 Mar 19 12:22 PM
hi,
did u use it?
data:G_TREE TYPE REF TO CL_GUI_LIST_TREE.
CALL METHOD G_TREE->ADD_NODES_AND_ITEMS
EXPORTING
NODE_TABLE = NODE_TABLE
ITEM_TABLE = ITEM_TABLE
ITEM_TABLE_STRUCTURE_NAME = 'MTREEITM'
EXCEPTIONS
FAILED = 1
CNTL_SYSTEM_ERROR = 3
ERROR_IN_TABLES = 4
DP_ERROR = 5
TABLE_STRUCTURE_NAME_NOT_FOUND = 6.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
regards,
bharat.
‎2007 Mar 19 12:30 PM
‎2007 Mar 19 12:33 PM
hi,
which type of tree u r using?
list/simple/column tree.
regard,
bharat.
‎2007 Mar 19 12:36 PM
‎2007 Mar 19 12:43 PM
hi,
did u create a container.
data:G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
(this becomes the parent of ur tree)
create a container for the tree control
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'TREE_CONTAINER'(the name of the container u've created on the screen)
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
‎2007 Mar 19 12:48 PM
Thanks Bharat!!! I have wrong the name of the container!!! I had the name 'CR_ARBOL' and the containers name was 'C_ARBOL'.
‎2007 Mar 19 12:38 PM
Hi Jorge,
go through the following Code
class: lcl_application definition deferred.
tables : vbrk.
data : it_vbrk like vbrk occurs 0 with header line.
data : it_vbrp like vbrp occurs 0.
data : it_dir like vbrk.
data : g_application type ref to lcl_application,
g_custom_container type ref to cl_gui_custom_container,
g_tree type ref to cl_gui_simple_tree,
o_cont type ref to cl_gui_custom_container,
o_grid type ref to cl_gui_alv_grid.
*--Declaration for Tree View
data : g_node_key type tv_nodekey, " Holds Node Key Value
node_nb type i. "for Node key
Types : node_table_type like standard table of mtreesnode with default key.
select-options : s_vbeln for vbrk-vbeln.
select-options : s_fkart for vbrk-fkart.
class lcl_application definition.
public section.
*--Event Handler method, this will be executed when
*--node_double click event is triggered.
*--Node_key is passed as an input to this method to
*--know which node was clicked
methods : handle_node_double_click for event
node_double_click of cl_gui_simple_tree
importing node_key,
handle_expand_no_children for event
expand_no_children of cl_gui_simple_tree
importing node_key.
endclass.
class lcl_application implementation.
method handle_node_double_click.
g_node_key = node_key.
refresh it_vbrp.
read table it_vbrk into it_dir index g_node_key.
select * from vbrp into table it_vbrp
where vbeln = it_dir-vbeln.
CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'VBRP'
CHANGING
IT_OUTTAB = it_vbrp.
CALL METHOD O_GRID->REFRESH_TABLE_DISPLAY.
endmethod.
method handle_expand_no_children.
data : g_node_table type node_table_type,
node type mtreesnode,
node_chemin(255) type c,
it_dir type vbrk.
g_node_key = node_key.
read table it_vbrk into it_dir index g_node_key.
if sy-subrc = 0.
node_chemin = it_dir-vbeln.
else.
exit.
endif.
loop at it_vbrk into it_dir.
clear : node.
node-node_key = node_nb.
node-relatkey = node_key.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = it_vbrk-vbeln.
node-isfolder = 'X'.
node-expander = 'X'.
if not it_dir-vbeln is initial.
append node to g_node_table.
node_nb = node_nb + 1.
endif.
endloop.
loop at it_vbrk into it_dir.
at new fkart.
clear : node.
node-node_key = node_nb.
node-relatkey = node_key.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = it_vbrk-vbeln.
node-isfolder = 'X'.
node-expander = 'X'.
if not it_dir-vbeln is initial.
append node to g_node_table.
node_nb = node_nb + 1.
endif.
endat.
endloop.
if sy-subrc = 0.
CALL METHOD G_TREE->ADD_NODES
EXPORTING
TABLE_STRUCTURE_NAME = 'MTREESNODE'
NODE_TABLE = g_node_table.
endif.
endmethod.
endclass.
start-of-selection.
perform get_data.
create object g_application.
set screen 100.
&----
*& Form get_data
&----
text
----
FORM get_data .
select vbeln from vbrk
into corresponding fields of table it_vbrk
where vbeln in s_vbeln.
if sy-subrc = 0.
sort it_vbrk by fkart.
endif.
ENDFORM. " get_data
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MENU'.
if g_tree is initial.
perform create_and_init_tree.
endif.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
when 'BACK'.
leave program.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form create_and_init_tree
&----
text
----
FORM create_and_init_tree .
data : events type cntl_simple_events,
event type cntl_simple_event.
*--Creating Custom Container class object and passing
*--custom control to it to link.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'TREE_CONT'.
*--Linking Tree View class object to Custom Container class object
*--so that Tree View control will sit on Custom control of the
*--graphical screen.
CREATE OBJECT G_TREE
EXPORTING
PARENT = g_custom_container
NODE_SELECTION_MODE = cl_gui_simple_tree=>node_sel_mode_single.
*--Registering the event id for Tree View which system
*--uses internal purpose.
event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
event-appl_event = 'X'.
append event to events.
*--Registering the eventId for Tree View.
CALL METHOD G_TREE->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = EVENTS.
assign event handlers in the application class to each desired event
SET HANDLER G_APPLICATION->HANDLE_NODE_DOUBLE_CLICK FOR G_TREE.
SET HANDLER G_APPLICATION->HANDLE_EXPAND_NO_CHILDREN FOR G_TREE.
perform build_node_table.
ENDFORM. " create_and_init_tree
&----
*& Form build_node_table
&----
FORM build_node_table..
data : g_node_table type node_table_type,
it_dir like vbrk,
node type mtreesnode.
*--Creating the first Root node of the Tree View Control.
clear : node,
node_nb.
node-node_key = '0'.
node-isfolder = 'X'.
node-text = 'Sales Orders'.
append node to g_node_table.
node_nb = node_nb + 1.
*--Creating the Child Node and adding that to the root node.
loop at it_vbrk into it_dir.
clear node.
node-node_key = node_nb.
*--Adding the Child node to the root node(Sales Order Folder)
node-relatkey = '0'.
node-relatkey = node_nb.
*--Adding the New Child node, Next to last Child Node
node-relatship = cl_gui_simple_tree=>relat_last_child.
append node to g_node_table.
*--Showing the sales order no as a text to the node.
node-text = it_dir-vbeln.
node-isfolder = 'X'.
node-expander = 'X'.
node-n_image = '@1Z@'.
if not it_dir-vbeln is initial.
append node to g_node_table.
node_nb = node_nb + 1.
endif.
endloop.
*--Loading the Nodes into tree view control.
if sy-subrc = 0.
CALL METHOD G_TREE->ADD_NODES
EXPORTING
TABLE_STRUCTURE_NAME = 'MTREESNODE'
NODE_TABLE = g_node_table.
endif.
CREATE OBJECT O_CONT
EXPORTING
CONTAINER_NAME = 'CUST_CONT'.
if sy-subrc = 0.
CREATE OBJECT O_GRID
EXPORTING
I_PARENT = O_CONT.
endif.
ENDFORM. " build_node_table
<b> set screen 100.</b>
here you just double click on this screen Number 100.
and place two subscreen here.
one for : TREE_CONT and other for CUST_CONT
Thanks & regards
Sreeni
‎2007 Mar 19 12:43 PM
Thanks but i have made yhe report and I can´t change it. i need to know why a ALV tree can´t be displayed.
Thanks.
‎2007 Mar 19 12:50 PM
hi,
i think u r writing all the code in the program.
you have to write all the code to create the tree in one of the module of PBO.
confirm whether u r doing so are not.
regards,
bharat.
‎2007 Mar 19 1:20 PM
Hi Sreenivasulu,
Thanks for your program, its really useful.
Thanks
Satya