‎2007 Aug 22 8:47 AM
hi guys,
i am new to ALV TREE and i dont know how to make alv tree, can someone please help me to make ALV TREE or better yet, give me the complete codes with all its includes so that i can study how to make ALV TREE. please..
thanks very much.. i will surely reward points for this. thanks guys..i appreciate those who will help me..thanks..
‎2007 Aug 22 8:52 AM
Hi,
see the system defined programs SAPTLIST*
there u can get demo programs.
<b>reward if helpful</b>
rgds,
bharat.
‎2007 Aug 22 8:52 AM
Hi,
Check the programs
BCALV_TEST_SIMPLE_TREE.
BCALV_TREE_01
BCALV_TREE_02
BCALV_TREE_03
BCALV_TREE_04
BCALV_TREE_05
BCALV_TREE_06
BCALV_TREE_DEMO
BCALV_TREE_DND
BCALV_TREE_DND_MULTIPLE
BCALV_TREE_ITEMLAYOUT
BCALV_TREE_MOVE_NODE_TEST
BCALV_TREE_VERIFY
Regards,
Sesh
‎2007 Aug 22 9:02 AM
Hi
Some Helpful Links -
http://www.sapdevelopment.co.uk/reporting/alv/alvtree%5Calvtree_basic.htm
You can Study Standard SAP Programs for ALV - BCALV_TREE_SIMPLE_DEMO
report bcalv_tree_simple_demo.
class cl_gui_column_tree definition load.
class cl_gui_cfw definition load.
data tree1 type ref to cl_gui_alv_tree_simple.
include <icon>.
include bcalv_simple_event_receiver.
data: gt_sflight type sflight occurs 0, "Output-Table
gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
gt_sort type lvc_t_sort, "Sortiertabelle
ok_code like sy-ucomm. "OK-Code
start-of-selection.
end-of-selection.
call screen 100.
&----
*& Form BUILD_FIELDCATALOG
&----
text
----
form build_fieldcatalog.
get fieldcatalog
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'SFLIGHT'
changing
ct_fieldcat = gt_fieldcatalog.
change fieldcatalog
data: ls_fieldcatalog type lvc_s_fcat.
loop at gt_fieldcatalog into ls_fieldcatalog.
case ls_fieldcatalog-fieldname.
when 'CARRID' or 'CONNID' or 'FLDATE'.
ls_fieldcatalog-no_out = 'X'.
ls_fieldcatalog-key = ''.
when 'PRICE' or 'SEATSOCC' or 'SEATSMAX' or 'PAYMENTSUM'.
ls_fieldcatalog-do_sum = 'X'.
endcase.
modify gt_fieldcatalog from ls_fieldcatalog.
endloop.
endform. " BUILD_FIELDCATALOG
&----
*& Form BUILD_OUTTAB
&----
text
----
--> p1 text
<-- p2 text
----
form build_outtab.
select * from sflight into table gt_sflight.
up to 1 rows.
endform. " BUILD_OUTTAB
&----
*& Form BUILD_SORT_TABLE
&----
text
----
--> p1 text
<-- p2 text
----
form build_sort_table.
data ls_sort_wa type lvc_s_sort.
create sort-table
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = 'CARRID'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
append ls_sort_wa to gt_sort.
ls_sort_wa-spos = 2.
ls_sort_wa-fieldname = 'CONNID'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
append ls_sort_wa to gt_sort.
ls_sort_wa-spos = 3.
ls_sort_wa-fieldname = 'FLDATE'.
ls_sort_wa-up = 'X'.
append ls_sort_wa to gt_sort.
endform. " BUILD_SORT_TABLE
&----
*& Module PBO OUTPUT
&----
text
----
module pbo output.
if tree1 is initial.
perform init_tree.
endif.
set pf-status 'MAIN100'.
endmodule. " PBO OUTPUT
&----
*& Module PAI INPUT
&----
text
----
module pai input.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
perform exit_program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
clear ok_code.
endmodule. " PAI INPUT
&----
*& Form exit_program
&----
free object and leave program
----
form exit_program.
call method tree1->free.
leave program.
endform. " exit_program
&----
*& Form register_events
&----
text
----
--> p1 text
<-- p2 text
----
form register_events.
define the events which will be passed to the backend
data: lt_events type cntl_simple_events,
l_event type cntl_simple_event.
define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
append l_event to lt_events.
call method tree1->set_registered_events
exporting
events = lt_events
exceptions
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
set Handler
data: l_event_receiver type ref to lcl_tree_event_receiver.
create object l_event_receiver.
set handler l_event_receiver->on_add_hierarchy_node
for tree1.
endform. " register_events
&----
*& Form build_header
&----
build table for html_header
----
--> p1 text
<-- p2 text
----
form build_comment using
pt_list_commentary type slis_t_listheader
p_logo type sdydo_value.
data: ls_line type slis_listheader.
*
LIST HEADING LINE: TYPE H
clear ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'ALV-tree-simple-Demo: flight-overview'. "#EC NOTEXT
append ls_line to pt_list_commentary.
STATUS LINE: TYPE S
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = 'valid to'. "#EC NOTEXT
ls_line-info = 'January 29 1999'. "#EC NOTEXT
append ls_line to pt_list_commentary.
ls_line-key = 'time'.
ls_line-info = '2.00 pm'. "#EC NOTEXT
append ls_line to pt_list_commentary.
ACTION LINE: TYPE A
clear ls_line.
ls_line-typ = 'A'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'up-to-date data'. "#EC NOTEXT
append ls_line to pt_list_commentary.
p_logo = 'ENJOYSAP_LOGO'.
endform.
&----
*& Form init_tree
&----
text
----
--> p1 text
<-- p2 text
----
FORM init_tree.
perform build_fieldcatalog.
perform build_outtab.
perform build_sort_table.
create container for alv-tree
data: l_tree_container_name(30) type c,
l_custom_container type ref to cl_gui_custom_container.
l_tree_container_name = 'TREE1'.
create object l_custom_container
exporting
container_name = l_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
create tree control
create object tree1
exporting
i_parent = l_custom_container
i_node_selection_mode =
cl_gui_column_tree=>node_sel_mode_multiple
i_item_selection = 'X'
i_no_html_header = ''
i_no_toolbar = ''
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
create info-table for html-header
data: lt_list_commentary type slis_t_listheader,
l_logo type sdydo_value.
perform build_comment using
lt_list_commentary
l_logo.
repid for saving variants
data: ls_variant type disvariant.
ls_variant-report = sy-repid.
register events
perform register_events.
create hierarchy
call method tree1->set_table_for_first_display
exporting
it_list_commentary = lt_list_commentary
i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
changing
it_sort = gt_sort
it_outtab = gt_sflight
it_fieldcatalog = gt_fieldcatalog.
expand first level
call method tree1->expand_Tree
exporting
i_level = 1.
optimize column-width
call method tree1->column_optimize
exporting
i_start_column = tree1->c_hierarchy_column_name
i_end_column = tree1->c_hierarchy_column_name.
ENDFORM. " init_tree