Application Development 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: 

CL_GUI_LIST_TREE->get_item

Former Member
0 Kudos

How can I use this method to get Item property?

Expecialy for CHOSEN property...

2 REPLIES 2

Former Member
0 Kudos

Hi,

This method is basically called when an event is triggered on a TREE.

to get the item property you firt have to specify one of the events. E.g. event NODE_DOUBLE_CLICK

and the event handler will have this method GET_ITEM which inturn returns the NODE_KEY, ITEM_NAME, ITEM for the selected node.

I hope this is the desired answer.

regards,

Kinshuk Saxena

0 Kudos

You need to declare an event handler for the click event. Something in this realm:

  • Treeview values below

class lcl_app definition deferred.

*class cl_gui_cfw definition load.

data: gGUI type ref to cl_gui_cfw.

data: NodeKey type tv_nodekey.

data: TempKey like NodeKey.

data: gContainer type ref to cl_gui_custom_container.

data: gApp type ref to lcl_app.

data: events type cntl_simple_events,

event type cntl_simple_event.

TYPES: ITEM_TABLE_TYPE LIKE STANDARD TABLE OF MTREEITM

WITH DEFAULT KEY.

data: list_tree type ref to CL_GUI_LIST_TREE.

data: TREEV_NODE_SEL_MODE_SINGLE TYPE I VALUE 0.

DATA: NODE_TABLE TYPE TREEV_NTAB,

ITEM_TABLE TYPE ITEM_TABLE_TYPE.

DATA: NODE TYPE TREEV_NODE,

ITEM TYPE MTREEITM.

class lcl_app definition.

public section.

methods:

handle_node_double_click

for event node_double_click

of cl_gui_list_tree

importing Node_Key.

endclass.

class lcl_app implementation.

method handle_node_double_click.

data: wa type MTREEITM.

TempKey = node_key. "Store off clicked field.

read table item_table into wa with key node_key = TempKey

item_name = '1'.

if sy-subrc = 0

and wa-text = 'Delivery:'.

read table item_table into wa with key node_key = TempKey

item_name = '2'.

if sy-subrc = 0.

g_DelNum = wa-text.

clear int_wa. refresh int_wa.

leave to screen '0200'.

endif.

endif.

endmethod.

endclass.

FORM Create_Tree .

  • Create treeview.

data: hierarchy_header type treev_hhdr,

list_header type treev_lhdr.

  • setup the hierarchy header

hierarchy_header-width = 43.

hierarchy_header-heading = 'Shipping point / Shipment / Delivery'.

create object gContainer

exporting

container_name = 'TREEVIEW_CONTROL1'

exceptions

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

IF SY-SUBRC <> 0.

MESSAGE A000.

ENDIF.

CREATE OBJECT LIST_TREE

EXPORTING

PARENT = gContainer

NODE_SELECTION_MODE = TREEV_NODE_SEL_MODE_SINGLE

ITEM_SELECTION = ' '

WITH_HEADERS = 'X'

HIERARCHY_HEADER = hierarchy_header.

event-eventid = cl_gui_list_tree=>eventid_node_double_click.

event-appl_event = 'X'.

append event to events.

event-eventid = cl_gui_list_tree=>eventid_expand_no_children.

event-appl_event = 'X'.

append event to events.

CALL METHOD LIST_TREE->SET_REGISTERED_EVENTS

EXPORTING

EVENTS = EVENTS

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

ILLEGAL_EVENT_COMBINATION = 3.

IF SY-SUBRC <> 0.

MESSAGE A000.

ENDIF.

  • assign event handlers in the application class to each desired event

SET HANDLER gApp->HANDLE_NODE_DOUBLE_CLICK FOR LIST_TREE.

Perform Load_Tree.

CALL METHOD LIST_TREE->ADD_NODES_AND_ITEMS

EXPORTING

NODE_TABLE = Node_TABLE

ITEM_TABLE = ITEM_TABLE

ITEM_TABLE_STRUCTURE_NAME = 'MTREEITM'

EXCEPTIONS

FAILED = 1

CNTL_SYSTEM_ERROR = 3

ERROR_IN_TABLES = 4

DP_ERROR = 5

TABLE_STRUCTURE_NAME_NOT_FOUND = 6.

IF SY-SUBRC <> 0.

MESSAGE A000.

ENDIF.

ENDFORM. " Create_Tree