06-24-2008 1:11 PM
Hi,
how can i use event LINK_CLICK in list tree.
Plz help me.
Regards ,
Venkat.
06-24-2008 1:18 PM
use this....
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS on_expand_no_children
FOR EVENT expand_no_children OF cl_gui_simple_tree
IMPORTING node_key sender.
METHODS on_node_double_click
FOR EVENT node_double_click OF cl_gui_simple_tree
IMPORTING node_key sender.
ENDCLASS.
************************************************************************
CLASS cl_event_receiver
IMPLEMENTATION
************************************************************************
CLASS cl_event_receiver IMPLEMENTATION.
*----
Triggering event: expand_no_children
Handling method: on_expand_no_children
Description:
The handling method is called whenever a node is supposed to be
expanded (by clicking on the expander icon) while subordinate entries
are not yet known in the GUI.
In this case the node table must be complemented with the respective
entries.
*----
METHOD on_expand_no_children.
IF SENDER <> obj_simple_tree.
EXIT.
ENDIF.
Determine subnodes
REFRESH t_gui_node.
LOOP AT t_node INTO wa_node WHERE relatkey = node_key.
APPEND wa_node TO t_gui_node.
ENDLOOP.
Send node table to GUI
CALL METHOD obj_simple_tree->ADD_NODES
EXPORTING
TABLE_STRUCTURE_NAME = 'MTREESNODE'
NODE_TABLE = t_gui_node
EXCEPTIONS
ERROR_IN_NODE_TABLE = 1
FAILED = 2
DP_ERROR = 3
TABLE_STRUCTURE_NAME_NOT_FOUND = 4
others = 5.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'at methode ADD_NODES'.
ENDIF.
ENDMETHOD.
*----
Triggering event: node_double_click
Handling method: on_node_double_click
The handling method is called every time a double-click is executed
on a node or a leaf.
*----
METHOD on_node_double_click.
IF SENDER <> obj_simple_tree.
EXIT.
ENDIF.
Output message for selected node or leaf
CLEAR wa_node.
READ TABLE t_node
WITH KEY node_key = node_key
INTO wa_node.
IF SY-SUBRC = 0.
IF wa_node-isfolder = 'X'.
MESSAGE i398(00)
WITH 'Double-click on node' wa_node-node_key.
ELSE.
MESSAGE i398(00)
WITH 'Double-click on leaf' wa_node-node_key.
ENDIF.
ELSE.
MESSAGE i398(00)
WITH 'Double-click on unknown node'.
ENDIF.
Trigger PAI and transfer function code (system event)
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING new_code = 'FCODE_DOUBLECLICK'.
ENDMETHOD.
ENDCLASS.
&----
*& Module STATUS_0100 OUTPUT
&----
GUI status for dynpro
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'DYN_0100'.
SET TITLEBAR 'DYN_0100'.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module create_objects OUTPUT
&----
Create instances
----
MODULE create_objects OUTPUT.
IF NOT obj_custom_container IS INITIAL.
EXIT.
ENDIF.
----
Create instance for custom container
----
CREATE OBJECT obj_custom_container
EXPORTING
PARENT =
CONTAINER_NAME = 'DYNPRO_CONTAINER'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
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 i398(00) WITH 'Error' sy-subrc
'when creating the custom container controls'.
ENDIF.
----
Create instance (back-end) for Simple Tree Model
----
CREATE OBJECT obj_simple_tree
EXPORTING
NODE_SELECTION_MODE = CL_SIMPLE_TREE_MODEL=>NODE_SEL_MODE_SINGLE
HIDE_SELECTION =
EXCEPTIONS
ILLEGAL_NODE_SELECTION_MODE = 1
others = 2.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when creating the Simple Tree Model'.
ENDIF.
----
Create instance (representative object for control at front end)
----
CALL METHOD obj_simple_tree->CREATE_TREE_CONTROL
EXPORTING
LIFETIME =
PARENT = obj_custom_container
SHELLSTYLE =
IMPORTING
CONTROL =
EXCEPTIONS
LIFETIME_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
FAILED = 4
TREE_CONTROL_ALREADY_CREATED = 5
others = 6.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when creating the Simple Tree Control'.
ENDIF.
ENDMODULE. " create_objects OUTPUT
&----
*& Module register_events OUTPUT
&----
Event handling
----
MODULE register_events OUTPUT.
----
Register events as system event at CFW *
----
CLEAR t_events.
Register event for double-click
CLEAR wa_event.
wa_event-eventid = CL_SIMPLE_TREE_MODEL=>EVENTID_NODE_DOUBLE_CLICK.
wa_event-appl_event = ' '.
APPEND wa_event TO t_events.
Register events at CFW and control at front end
CALL METHOD obj_simple_tree->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = t_events
EXCEPTIONS
ILLEGAL_EVENT_COMBINATION = 1
UNKNOWN_EVENT = 2
others = 3.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'when registering the events'.
ENDIF.
----
Create event handler and register events
----
IF obj_event_receiver IS INITIAL.
CREATE OBJECT obj_event_receiver.
SET HANDLER obj_event_receiver->on_node_double_click
FOR obj_simple_tree.
SET HANDLER obj_event_receiver->on_expand_no_children
FOR obj_simple_tree.
ENDIF.
ENDMODULE. " register_events OUTPUT
&----
*& Module create_tree OUTPUT
&----
Create node table with root and 1st level
----
MODULE create_tree OUTPUT.
IF NOT t_node IS INITIAL.
EXIT.
ENDIF.
----
Create node table
----
PERFORM fill_node_table.
----
Fill node table t_gui_node for control
----
REFRESH t_gui_node.
t_gui_node = t_node.
----
Transfer entire node table to Simple Tree Model
----
CALL METHOD obj_simple_tree->ADD_NODES
EXPORTING
NODE_TABLE = t_gui_node
EXCEPTIONS
ERROR_IN_NODE_TABLE = 1
others = 2.
IF SY-SUBRC <> 0.
MESSAGE i398(00) WITH 'Error' sy-subrc
'at methode ADD_NODES'.
ENDIF.
ENDMODULE. " create_tree OUTPUT