‎2006 Aug 21 11:40 AM
Dear Friends
I do have problem with ALV Tree Display. Hope someone
here can help to identify any bug which i might have
left through ignorance.
<b>Problem</b>: Am trying to display an output in tree
format with reference to program: BCALV_TREE_DEMO. I can
see the root node being displayed, but when i try to
expand the list it goes to dump.
Dump Name: <b>GETWA_NOT_ASSIGNED</b>.
Found out through debugging that the field-symbol which
refers to the data is being refreshed and hence unable
to assign the fields. Tried to compare with the standard
program program but couldnt get any clue. Hope someone
can identify where i am going wrong.
Code Details:
......
class cl_gui_column_tree definition load.
class cl_gui_cfw definition load.
data tree1 type ref to cl_gui_alv_tree.
data mr_toolbar type ref to cl_gui_toolbar.
include <icon>.
include bcalv_toolbar_event_receiver.
include bcalv_tree_event_receiver.
data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
......
CALL SCREEN 100.
......
MODULE PBO OUTPUT.
SET PF-STATUS 'MAIN100'.
IF TREE1 IS INITIAL.
PERFORM SHOW_LIST.
ENDIF.
call method cl_gui_cfw=>flush.
ENDMODULE. " PBO OUTPUT
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.
call method cl_gui_cfw=>flush.
ENDMODULE. " PAI INPUT
FORM exit_program .
call method tree1->free.
leave program.
ENDFORM. " exit_program
FORM SHOW_LIST .
PERFORM BUILD_CATALOG.
* 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'.
if sy-batch is initial.
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.
if sy-subrc <> 0.
message x208(00) with 'ERROR'.
endif.
endif.
* create tree control
create object tree1
exporting
parent = l_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = ''
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.
if sy-subrc <> 0.
message x208(00) with 'ERROR'.
endif.
* create Hierarchy-header
data l_hierarchy_header type treev_hhdr.
perform build_hierarchy_header changing l_hierarchy_header.
* 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.
data: it_out type t_final OCCURS 0.
* create emty tree-control
call method tree1->set_table_for_first_display
exporting
is_hierarchy_header = l_hierarchy_header
it_list_commentary = lt_list_commentary
i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
changing
it_outtab = it_out "table must be emty !!
it_fieldcatalog = it_fieldcat.
* create hierarchy
perform create_hierarchy.
* register events
perform register_events.
ENDFORM. " SHOW_LIST
FORM build_hierarchy_header
CHANGING p_hierarchy_header type treev_hhdr.
p_hierarchy_header-heading = 'BOM Material'.
p_hierarchy_header-tooltip =
'BOM Material'.
p_hierarchy_header-width = 32.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
FORM build_comment USING pt_list_commentary type slis_t_listheader
p_logo type sdydo_value.
data: ls_line type slis_listheader.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = 'BOM Pricing Report'.
append ls_line to pt_list_commentary.
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Date:'.
concatenate sy-datum+6(2) '/' sy-datum+4(2) '/' sy-datum(4)
into ls_line-info.
append ls_line to pt_list_commentary.
ls_line-key = 'Time'.
concatenate sy-uzeit(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
into ls_line-info.
append ls_line to pt_list_commentary.
ENDFORM. " build_comment
FORM create_hierarchy .
DATA: L_NODE_KEY TYPE LVC_NKEY,
L_NODE_KEY1 TYPE LVC_NKEY,
L_NODE_KEY2 TYPE LVC_NKEY.
DATA: WA_FINAL TYPE T_FINAL.
LOOP AT IT_FINAL INTO WA_FINAL.
ON CHANGE OF WA_FINAL-MATNR.
PERFORM ADD_PARENT_LINE USING WA_FINAL L_NODE_KEY
CHANGING L_NODE_KEY1.
ENDON.
PERFORM ADD_ITEM_LINE USING WA_FINAL L_NODE_KEY1
CHANGING L_NODE_KEY2.
ENDLOOP.
call method tree1->frontend_update.
ENDFORM. " create_hierarchy
FORM ADD_PARENT_LINE USING LS_FINAL TYPE T_FINAL P_REL_KEY CHANGING
P_NODE_KEY.
data: l_node_text type lvc_value.
DATA: WA_FINAL TYPE T_FINAL.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
append ls_item_layout to lt_item_layout.
* add node
l_node_text = LS_FINAL-MATNR.
MOVE: LS_FINAL-MATNR TO WA_FINAL-MATNR,
LS_FINAL-STLNR TO WA_FINAL-STLNR,
LS_FINAL-PRICE TO WA_FINAL-PRICE,
LS_FINAL-KONWA TO WA_FINAL-KONWA.
call method tree1->add_node
exporting
i_relat_node_key = p_rel_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = WA_FINAL
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
ENDFORM. " ADD_PARENT_LINE
FORM ADD_ITEM_LINE USING LS_FINAL TYPE T_FINAL
P_REL_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
data: l_node_text type lvc_value.
DATA: WA_FINAL TYPE T_FINAL.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
append ls_item_layout to lt_item_layout.
l_node_text = LS_FINAL-COMP.
MOVE: LS_FINAL-COMP TO WA_FINAL-COMP,
LS_FINAL-DATAB TO WA_FINAL-DATAB,
LS_FINAL-DATBI TO WA_FINAL-DATBI,
LS_FINAL-KBETR TO WA_FINAL-KBETR,
LS_FINAL-KONWA TO WA_FINAL-KONWA.
call method tree1->add_node
exporting
i_relat_node_key = P_REL_KEY
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = WA_FINAL
i_node_text = l_node_text
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
ENDFORM. " ADD_ITEM_LINE
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_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
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_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_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.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
* set Handler
data: l_event_receiver type ref to lcl_tree_event_receiver.
create object l_event_receiver.
set handler l_event_receiver->handle_node_ctmenu_request
for tree1.
set handler l_event_receiver->handle_node_ctmenu_selected
for tree1.
set handler l_event_receiver->handle_item_ctmenu_request
for tree1.
set handler l_event_receiver->handle_item_ctmenu_selected
for tree1.
call method cl_gui_cfw=>flush.
ENDFORM. " register_events
Should you require more details i can provide you.
Thanks in Advance.
Thanks & Regards
Tony
‎2006 Aug 21 11:42 AM
Hai Tony,
Kindly check your field catalog. There may be error in the field catalog. Check the field names.
‎2006 Aug 21 11:50 AM
HI Sakthi
Thanks for your response. Am using the same structure
for both Header and Item details.
Below is the same for your understanding:
FORM ADD_PARENT_LINE USING LS_FINAL TYPE T_FINAL P_REL_KEY CHANGING
P_NODE_KEY.
data: l_node_text type lvc_value.
DATA: WA_FINAL TYPE T_FINAL.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
append ls_item_layout to lt_item_layout.
* add node
l_node_text = LS_FINAL-MATNR.
MOVE: LS_FINAL-MATNR TO WA_FINAL-MATNR,
LS_FINAL-STLNR TO WA_FINAL-STLNR,
LS_FINAL-PRICE TO WA_FINAL-PRICE,
LS_FINAL-KONWA TO WA_FINAL-KONWA.
call method tree1->add_node
exporting
i_relat_node_key = p_rel_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = WA_FINAL
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
ENDFORM. " ADD_PARENT_LINE
FORM ADD_ITEM_LINE USING LS_FINAL TYPE T_FINAL
P_REL_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
data: l_node_text type lvc_value.
DATA: WA_FINAL TYPE T_FINAL.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
append ls_item_layout to lt_item_layout.
l_node_text = LS_FINAL-COMP.
MOVE: LS_FINAL-COMP TO WA_FINAL-COMP,
LS_FINAL-DATAB TO WA_FINAL-DATAB,
LS_FINAL-DATBI TO WA_FINAL-DATBI,
LS_FINAL-KBETR TO WA_FINAL-KBETR,
LS_FINAL-KONWA TO WA_FINAL-KONWA.
call method tree1->add_node
exporting
i_relat_node_key = P_REL_KEY
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = WA_FINAL
i_node_text = l_node_text
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
ENDFORM. " ADD_ITEM_LINE
I can see that the data has been populated in a right
way for the first output.
Field-Symbol: MT_OUTTAB which stores the data being
populated is having values when method
set_items_for_column is called upon the first execution
but the same has been refreshed when i try to expand
whereas in the demo program it still has the values.
Any other advice.
Thanks & Regards
TonyMessage was edited by: Tony Jaand
Message was edited by: Tony Jaand
‎2006 Aug 21 11:58 AM
Hai Tony,
You might have noted that the size of the internal table that you are passing increases. Since the table is manipulated by SAP method add_node. Check the values of the internal table after each time of add_node call. Possible you can change the Class CL_GUI_COLUMN_TREE.
‎2006 Aug 21 2:39 PM
Thanks Sakthi
Changes to Field Catalog and Other declarations has avoided the dump.
Thanks & Regards
Tony