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

Simple tree view control

Former Member
0 Likes
692

Hi,

i am going through the example SAPSIMPLE_TREE_MODEL_DEMO

could some one give me a insight look at this areas

1.In export parameter we used 'node_selection_mode = cl_simple_tree_model=>node_sel_mode_single' creating an instance of gtree ?

*create a simple tree model instance

CREATE OBJECT g_tree

EXPORTING

node_selection_mode = cl_simple_tree_model=>node_sel_mode_single

2.wat does this mean

  • create the view (control) of the tree model

CALL METHOD g_tree->create_tree_control

EXPORTING

parent = g_custom_container

EXCEPTIONS

lifetime_error = 1

cntl_system_error = 2

create_error = 3

failed = 4

tree_control_already_created = 5.

IF sy-subrc <> 0.

MESSAGE a001(s).

ENDIF.

3.how are events handeled .

  • define the events which will be passed to the backend

" node double click

event-eventid = cl_simple_tree_model=>eventid_node_double_click.

event-appl_event = 'X'. " process PAI if event occurs

APPEND event TO events.

CALL METHOD g_tree->set_registered_events

EXPORTING

events = events

EXCEPTIONS

illegal_event_combination = 1

unknown_event = 2.

IF sy-subrc <> 0.

MESSAGE a001(s).

ENDIF.

4.for event DOUBLE_CLICK this it uses an attribute which is unique eventid , how can i find eventids for other events

Thanks.

azee.

4 REPLIES 4
Read only

Former Member
0 Likes
603

Hi

1- You should define a your local class for the events and in your top define a variable like that class:

CLASS LCL_MY_EVENT DEFINITION DEFERRED.

DATA: G_APPLICATION TYPE REF TO LCL_MY_EVENT.

  • CLASS DEFINTION/IMPLEMENTATION

CLASS LCL_MY_EVENT DEFINITION.

PUBLIC SECTION.

METHODS:

HANDLE_NODE_DOUBLE_CLICK

FOR EVENT NODE_DOUBLE_CLICK

OF CL_GUI_SIMPLE_TREE

IMPORTING NODE_KEY,

...........

ENDCLASS.

CLASS LCL_MY_CLASS IMPLEMENTATION.

METHOD HANDLE_NODE_DOUBLE_CLICK.

............

ENDMETHOD.

ENDCLASS.

2- you should add the piece code to active the event:

CALL METHOD g_tree->set_registered_events

EXPORTING

events = events

EXCEPTIONS

illegal_event_combination = 1

unknown_event = 2.

IF sy-subrc <> 0.

MESSAGE a001(s).

ENDIF.

SET HANDLER G_APPLICATION->HANDLE_NODE_DOUBLE_CLICK FOR G_TREE.

Max

Read only

Former Member
0 Likes
603

Hi,

GO through this link

http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm

Hope this helps.

Kindly reward points and close the thread if ur problem got solved or else revert back with queries.

Read only

Former Member
0 Likes
603

Hi Max,

Thanx for ur reply ,well could u be a bit more elaborate in this areas

1.In export parameter we used 'node_selection_mode = cl_simple_tree_model=>node_sel_mode_single' creating an instance of gtree ?

*create a simple tree model instance

CREATE OBJECT g_tree

EXPORTING

node_selection_mode = cl_simple_tree_model=>node_sel_mode_single

2.wat does this mean

  • create the view (control) of the tree model

3.Wat is event-eventid ,For event DOUBLE_CLICK it uses an attribute which is unique eventid , how can i find eventids for other events

event-eventid = cl_simple_tree_model=>eventid_node_double_click.

event-appl_event = 'X'. " process PAI if event occurs

APPEND event TO events.

Thanks,

Azee

Read only

0 Likes
603

Hi

1. You're creating your tree in which only single

selection (of node) is allowed:

The class cl_simple_tree_model has a constant static attribute (CLASS-DATA) called node_sel_mode_single whose value is 0, so

you can write:

CREATE OBJECT g_tree

EXPORTING

node_selection_mode =

cl_simple_tree_model=>node_sel_mode_single.

or

CREATE OBJECT g_tree

EXPORTING

node_selection_mode = 0.

cl_simple_tree_model=>node_sel_mode_single mean you want use attribute node_sel_mode_single of class cl_simple_tree_model.

2. To show a TREE needs a customer container, so you

create a screen with a container.

Check the data g_custom_container, it should be filled with the name of container. You can see the container by screen painter.

3. See the class cl_simple_tree_model to find other event by transaction SE24;

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

Message was edited by: max bianchi

Message was edited by: max bianchi