Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Tree Event Problem

Former Member
0 Likes
559

Dear all

I have developed Alv tree report with customer controller (Left Panel). In right panel i have inserted input box in the screen. While double click the node or child node, I need to pass node name to input box. I have written events also. Anyone help me

Whan i am double click the node PAI event is not calling

My coding part

----


  • TREE_EVENT_RECEIVER *

----


class tree_event_receiver definition.

public section.

methods on_doubleclick

for event ITEM_DOUBLE_CLICK of cl_gui_alv_tree

importing node_key fieldname.

ENDCLASS. "lcl_handler DEFINITION

----


  • CLASS tree_event_receiver IMPLEMENTATION

----


  • ........ *

----


class tree_event_receiver implementation.

METHOD on_doubleclick.

  • first check if the node is a leaf.

data: lt_children type lvc_t_nkey.

CALL METHOD g_alv_tree->get_outtab_line

EXPORTING

i_node_key = node_key

IMPORTING

e_node_text = lv_E_NODE_TEXT

EXCEPTIONS

node_not_found = 1

others = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

TXT_PROJECT = lv_E_NODE_TEXT.

ENDMETHOD. "on_doubleclick

&----


*

*& Module STATUS_0100 OUTPUT

&----


  • text

----


module STATUS_0100 output.

SET PF-STATUS 'MAIN100'.

SET TITLEBAR 'MAINTITLE'.

IF g_alv_tree IS INITIAL.

PERFORM init_tree.

ENDIF.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

save_ok = ok_code.

CLEAR ok_code.

data: return_code type i.

CALL METHOD CL_GUI_CFW=>DISPATCH

importing return_code = return_code.

if return_code <> cl_gui_cfw=>rc_noevent.

" a control event occured => exit PAI

clear ok_code.

exit.

endif.

CASE save_ok.

WHEN 'EXIT' OR 'BACK' OR 'CANC'.

LEAVE TO SCREEN 0.

WHEN OTHERS.

CALL METHOD cl_gui_cfw=>dispatch.

ENDCASE.

CALL METHOD cl_gui_cfw=>flush.

endmodule.

START-OF-SELECTION.

CALL SCREEN 100.

&----


*& Form INIT_TREE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form INIT_TREE .

  • create container for alv-tree

DATA: l_tree_container_name(30) TYPE c.

l_tree_container_name = 'TREE_CONTAINER'.

CREATE OBJECT g_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'(100).

ENDIF.

  • create tree control

CREATE OBJECT g_alv_tree

EXPORTING

parent = g_custom_container

node_selection_mode = cl_gui_column_tree=>node_sel_mode_single

item_selection = 'X'

no_html_header = 'X'

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'. "#EC NOTEXT

ENDIF.

DATA l_hierarchy_header TYPE treev_hhdr.

PERFORM build_hierarchy_header CHANGING l_hierarchy_header.

  • Hide columns and sum up values initially using the fieldcatalog

PERFORM build_fieldcatalog.

DATA: ls_variant TYPE disvariant.

ls_variant-report = sy-repid.

CALL METHOD g_alv_tree->set_table_for_first_display

EXPORTING

  • i_structure_name = 'YSTR_PROJECTS'

is_hierarchy_header = l_hierarchy_header

i_save = 'A'

is_variant = ls_variant

CHANGING

it_outtab = LT_PROJECT1 "table must be empty !

it_fieldcatalog = gt_fieldcatalog.

  • Create hierarchy (nodes and leaves)

PERFORM create_hierarchy.

perform register_events.

  • CALL METHOD g_alv_tree->update_calculations.

  • Send data to frontend.

CALL METHOD g_alv_tree->frontend_update.

endform. " INIT_TREE

&----


*& Form REGISTER_EVENTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form REGISTER_EVENTS .

data: lt_events type cntl_simple_events,

l_event type cntl_simple_event.

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_ITEM_DOUBLE_CLICK.

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.

  • set Handler

data: l_event_receiver type ref to tree_event_receiver.

create object l_event_receiver.

set handler l_event_receiver->on_doubleclick for g_alv_tree.

call method g_alv_tree->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.

endform. " REGISTER_EVENTS

3 REPLIES 3
Read only

Former Member
0 Likes
488

Hi all

Any one help me for this tread

Read only

Former Member
0 Likes
488

Hi,

In ur PAI module ur Clear the ok_code,Remove that one it wil work properly..

&----


*& Module USER_COMMAND_0100 INPUT

&----


text

-


module USER_COMMAND_0100 input.

save_ok = ok_code.

CLEAR ok_code.

data: return_code type i.

CALL METHOD CL_GUI_CFW=>DISPATCH

importing return_code = return_code.

if return_code cl_gui_cfw=>rc_noevent.

" a control event occured => exit PAI

clear ok_code.

exit.

endif.

CASE save_ok.

WHEN 'EXIT' OR 'BACK' OR 'CANC'.

LEAVE TO SCREEN 0.

WHEN OTHERS.

CALL METHOD cl_gui_cfw=>dispatch.

ENDCASE.

Clear ok_code

-


> use here finally

CALL METHOD cl_gui_cfw=>flush.

endmodule.

Edited by: Upender Verma on Jan 2, 2009 7:57 AM

Edited by: Upender Verma on Jan 2, 2009 7:57 AM

Edited by: Upender Verma on Jan 2, 2009 7:58 AM

Read only

Former Member
0 Likes
488

hi,

have a look at transaction SE83 in folder SAP Technology -> Controls -> Tree Controls.

hope it helps.

thanks