Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Control Framework tree control event not trigerring

The event handle_node_double_click is not trigerring on the tree controls . I want to display the contents of the nodes on the text editor on trigerring of this event

&----


*& Report ZCONTROLS_TREE_TEDIT_SPITTER

*&

&----


*&

*&

&----


REPORT zcontrols_tree_tedit_spitter.

DATA : editor TYPE REF TO cl_gui_textedit,

tree TYPE REF TO cl_gui_simple_tree.

DATA : container TYPE REF TO cl_gui_custom_container,

splitter TYPE REF TO cl_gui_easy_splitter_container,

right TYPE REF TO cl_gui_container,

left TYPE REF TO cl_gui_container.

DATA : node_itab LIKE node_str OCCURS 0.

----


  • CLASS EVENT_HANDLER DEFINITION

----


*

----


CLASS event_handler DEFINITION.

PUBLIC SECTION.

METHODS : handle_node_double_click

FOR EVENT NODE_DOUBLE_CLICK OF cl_gui_simple_tree

IMPORTING node_key.

ENDCLASS. "EVENT_HANDLER DEFINITION

----


  • CLASS EVENT_HANDLER IMPLEMENTATION

----


*

----


CLASS event_handler IMPLEMENTATION.

METHOD handle_node_double_click.

perform node_double_click using node_key.

ENDMETHOD. "HANDLE_NODE_DOUBLE_CLICK

ENDCLASS. "EVENT_HANDLER IMPLEMENTATION

data : handler1 type ref to event_handler.

START-OF-SELECTION.

CALL SCREEN 9001.

&----


*& Module start OUTPUT

&----


  • text

----


MODULE start OUTPUT.

SET PF-STATUS 'ZSTAT1'.

IF container IS INITIAL.

CREATE OBJECT container

EXPORTING

container_name = 'CONTAINER_NAME'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CREATE OBJECT splitter

EXPORTING

parent = container

orientation = 1

name = 'Mohit'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

left = splitter->top_left_container.

right = splitter->bottom_right_container.

CREATE OBJECT editor

EXPORTING

parent = right

name = 'MohitEditor'

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

OTHERS = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CREATE OBJECT tree

EXPORTING

parent = left

node_selection_mode = tree->node_sel_mode_single

name = 'MohitTree'

EXCEPTIONS

lifetime_error = 1

cntl_system_error = 2

create_error = 3

failed = 4

illegal_node_selection_mode = 5

OTHERS = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

PERFORM fill_tree.

CALL METHOD tree->add_nodes

EXPORTING

table_structure_name = 'NODE_STR'

node_table = node_itab

EXCEPTIONS

error_in_node_table = 1

failed = 2

dp_error = 3

table_structure_name_not_found = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

create object handler1.

set handler handler1->handle_node_double_click for tree.

ENDIF.

ENDMODULE. " start OUTPUT

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • text

----


MODULE user_command_9001 INPUT.

CALL METHOD cl_gui_cfw=>dispatch.

ENDMODULE. " USER_COMMAND_9001 INPUT

&----


*& Form fill_tree

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_tree .

DATA : node LIKE node_str.

CLEAR node.

node-node_key = 'head_mohit'.

node-isfolder = 'X'.

node-text = 'Mohit'.

APPEND node TO node_itab.

CLEAR node.

node-node_key = 'Child1'.

node-relatkey = 'head_mohit'.

node-relatship = cl_gui_simple_tree=>relat_last_child.

node-text = 'Mohit is the best '.

APPEND node TO node_itab.

CLEAR node.

node-node_key = 'Child2'.

node-relatkey = 'head_mohit'.

node-relatship = cl_gui_simple_tree=>relat_last_child.

node-text = 'Mohit is the bestest '.

APPEND node TO node_itab.

CLEAR node.

node-node_key = 'head_JAIN'.

node-isfolder = 'X'.

node-text = 'jAIN'.

APPEND node TO node_itab.

CLEAR node.

node-node_key = 'Child3'.

node-relatkey = 'head_JAIN'.

node-relatship = cl_gui_simple_tree=>relat_next_sibling.

node-text = 'cnh INDIA '.

APPEND node TO node_itab.

CLEAR node.

node-node_key = 'Child4'.

node-relatkey = 'head_JAIN'.

node-relatship = cl_gui_simple_tree=>relat_last_child.

node-text = 'SAP '.

APPEND node TO node_itab.

ENDFORM. " fill_tree

&----


*& Form node_double_click

&----


  • text

----


  • -->P_NODE_KEY text

----


form node_double_click using p_node_key type TV_NODEKEY.

DATA : node LIKE node_str.

DATA textline(256).

DATA text_table LIKE STANDARD TABLE OF textline.

READ TABLE node_itab WITH KEY node_key = p_node_key

INTO node.

endform. " node_double_click

&----


*& Module exit INPUT

&----


  • text

----


module exit input.

CASE sy-ucomm.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " exit INPUT

Former Member
Not what you were looking for? View more on this topic or Ask a question