‎2008 Jan 10 12:22 PM
Hi , can anyone please help me with ALV Column Tree Design . I have my data in a table GT_ZVBAP , now i want to display this as an ALV Column Tree with a field say 'ITEM' (parent) . I have seen standard programs and all but am not able to comprehend them fully and customize them to my program , please help me .
‎2008 Jan 10 12:29 PM
‎2008 Jan 11 3:18 AM
Hi Sarvesh,
I have displayed my ALV Tree using OOPS
PFB The code Proceed step by step , Firstly pull all your data in one internal table
form alv_hierarchy_display .
try.
cl_salv_tree=>factory(
importing
r_salv_tree = ob_tree
changing
t_table = pass ur internal table ).
catch cx_salv_error.
message e003.
endtry.
Build the Tree structure for display in Hierarchial List.
perform supply_data using( pass ur internal table ).
*
include own functions by setting own status
ob_tree->set_screen_status(
pfstatus = '100'
report = sy-repid
set_functions = ob_tree->c_functions_all ).
*
set the columns technical
ob_columns = ob_tree->get_columns( ).
ob_columns->set_optimize( abap_true ).
*
Setting the Columns Technical and Using in ALV Columns
perform set_columns_technical using ob_columns.
*
display the table
ob_tree->display( ).
endform. " alv_hierarchy_display
&----
*& Form supply_data
&----
text
-
-->P_IT_FT_LIST text
-
form supply_data using p_it_ft_list type standard table.
SORT p_itab_empdetails by oprtuntdesc deptuntdesc orgunit.
loop at p_it_ft_list into wa_ft_list.
on change of wa_ft_list-oprtunit.
perform add_optunit_line using wa_ft_list
''
changing v_optunit_key.
endon.
on change of wa_ft_list-deptunit.
perform add_deptunit_line using wa_ft_list
v_optunit_key
changing v_deptunit_key.
endon.
on change of wa_ft_list-orgeh.
perform add_orgeh_line using wa_ft_list
v_deptunit_key
changing v_orgunit.
endon.
perform add_last_line using wa_ft_list
v_orgunit
changing v_last_key.
endloop.
endform. " supply_data
&----
*& Form add_optunit_line
&----
text
-
-->P_WA_FT_LIST text
-->P_1165 text
<--P_V_OPTUNIT_KEY text
-
form add_optunit_line using p_wa_ft_list type ty_ft_list
p_key type lvc_nkey
changing p_l_optunit_key type lvc_nkey.
data : wa_ft_list1 type ty_ft_list.
working with nodes
ob_nodes = ob_tree->get_nodes( ).
Moving the Emp Details of the Operating Unit Desc to the WorkArea
move p_wa_ft_list-oprtunit to wa_ft_list1-oprtunit.
move p_wa_ft_list-oprtuntdesc to wa_ft_list1-oprtuntdesc.
try.
add a new node
set the data for the nes node
ob_node = ob_nodes->add_node( related_node = p_key
data_row = wa_ft_list1
relationship =
cl_gui_column_tree=>relat_last_child ).
ob_node->set_text( text-018 ).
p_l_optunit_key = ob_node->get_key( ).
catch cx_salv_msg.
message e003.
endtry.
endform. " add_optunit_line
&----
*& Form add_deptunit_line
&----
text
-
-->P_WA_FT_LIST text
-->P_V_OPTUNIT_KEY text
<--P_V_DEPTUNIT_KEY text
-
form add_deptunit_line using p_wa_ft_list type ty_ft_list
p_l_orgeh type lvc_nkey
changing p_l_deptunit_key type lvc_nkey.
data : wa_ft_list2 type ty_ft_list.
working with nodes
ob_nodes = ob_tree->get_nodes( ).
Moving the Emp Details of the Dept Unit Desc to the WorkArea
move p_wa_ft_list-deptunit to wa_ft_list2-deptunit.
move p_wa_ft_list-deptuntdesc to wa_ft_list2-deptuntdesc.
try.
ob_node = ob_nodes->add_node( related_node = p_l_orgeh
data_row = wa_ft_list2
relationship =
cl_gui_column_tree=>relat_last_child ).
ob_node->set_text( text-005 ).
p_l_deptunit_key = ob_node->get_key( ).
catch cx_salv_msg.
message e003.
endtry.
endform. " add_deptunit_line
&----
*& Form add_orgeh_line
&----
text
-
-->P_WA_FT_LIST text
-->P_V_DEPTUNIT_KEY text
<--P_V_ORGUNIT text
-
form add_orgeh_line using p_wa_ft_list type ty_ft_list
p_key type lvc_nkey
changing p_l_orgeh type lvc_nkey.
data : wa_ft_list3 type ty_ft_list.
working with nodes
ob_nodes = ob_tree->get_nodes( ).
Moving the Work Area Details to Local WorkArea3
move p_wa_ft_list-orgeh to wa_ft_list3-orgeh.
move p_wa_ft_list-orgindeptdesc to wa_ft_list3-orgindeptdesc.
try.
add a new node
set the data for the nes node
ob_node = ob_nodes->add_node( related_node = p_key
data_row = wa_ft_list3
relationship =
cl_gui_column_tree=>relat_last_child ).
ob_node->set_text( text-004 ).
p_l_orgeh = ob_node->get_key( ).
catch cx_salv_msg.
message e003.
endtry.
endform. " add_orgeh_line
&----
*& Form add_last_line
&----
text
-
-->P_WA_FT_LIST text
-->P_V_ORGUNIT text
<--P_V_LAST_KEY text
-
form add_last_line using value(p_wa_ft_list) type ty_ft_list
value(p_l_optunit_key) type lvc_nkey
changing p_l_last_key type lvc_nkey.
working with nodes
ob_nodes = ob_tree->get_nodes( ).
clear: p_wa_ft_list-orgeh, " Clearing WorkArea
p_wa_ft_list-orgindeptdesc,
p_wa_ft_list-deptuntdesc,
p_wa_ft_list-oprtuntdesc,
p_wa_ft_list-deptunit,
p_wa_ft_list-oprtunit.
try.
ob_node = ob_nodes->add_node( related_node = p_l_optunit_key
data_row = p_wa_ft_list
relationship =
cl_gui_column_tree=>relat_last_child
).
p_l_last_key = ob_node->get_key( ).
catch cx_salv_msg.
message e003.
endtry.
endform.
kindly reward if found helpful.
cheers,
Hema.
‎2008 Jan 11 3:21 AM
Hi Sarvesh u can also do like this.
First write a program and then convert the program into alv tree column.
To convert your program into an alv tree take a look to BCALV_TREE_DEMO program.
In the form create_hierarchy insert the code that you have in the start-of-selection event and then register the event EXPAND_NO_CHILDREN. in the implement this method with the code that you have in the AT Line-Selection EVENT.
cheers,
Hema.
‎2008 Jan 11 6:22 AM
Hi,
The above mentioned program is good.
Also you may use thr SAP demo program for ALV Column tree
SAPSIMPLE_TREE_CONTROL_DEMO
This will help you.
Regards,
Renjith Michael.