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: 

Displaying Trees in lists

Former Member
0 Kudos
570

hi

can anybody plz tell me how implement tree structure in the display of a classical list. also plz tell me the place(in the net) where i can find examples for it.

1 ACCEPTED SOLUTION

former_member184495
Active Contributor
0 Kudos
185

hi narendiran,

try this out, and understand.

*----


Type-pools : fibs,stree.

data : t_node type snodetext.

data : node_tab like t_node occurs 0 with header line.

clear : node_tab, node_tab[].

node_tab-type = 'T'.

node_tab-name = 'ROOT'.

node_tab-tlevel = '01'.

node_tab-nlength = '5'.

node_tab-color = '4'.

node_tab-text = 'Root Node'.

node_tab-tlength ='11'.

node_tab-tcolor = 5.

append node_tab.

clear node_tab.

node_tab-type = 'P'.

node_tab-name = 'SubRoot'.

node_tab-tlevel = '02'.

node_tab-nlength = '8'.

node_tab-color = '1'.

node_tab-text = 'Sub Root Node'.

node_tab-tlength ='13'.

node_tab-tcolor = 3.

append node_tab.

clear node_tab.

node_tab-type = 'P'.

node_tab-name = 'Child Node'.

node_tab-tlevel = '04'.

node_tab-nlength = '11'.

node_tab-color = '4'.

node_tab-tlength ='5'.

node_tab-tcolor = 10.

append node_tab.

clear node_tab.

CALL FUNCTION 'RS_TREE_CONSTRUCT'

  • EXPORTING

  • INSERT_ID = '000000'

  • RELATIONSHIP = ' '

  • LOG =

TABLES

NODETAB = node_tab

  • EXCEPTIONS

  • TREE_FAILURE = 1

  • ID_NOT_FOUND = 2

  • WRONG_RELATIONSHIP = 3

  • OTHERS = 4

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

DATA: type_mapping TYPE stree_ctl_type_mapping_tab.

DATA: wa_type TYPE stree_ctl_type_mapping.

CLEAR: type_mapping[].

wa_type-type = 'A'.

wa_type-icon = '@BL@'.

APPEND wa_type TO type_mapping.

*CALL FUNCTION 'RS_TREE_CONTROL_PREPARE'

  • EXPORTING

    • CONTROL_PATTERN = STREE_CTL_GENERIC

  • CONTROL_PATTERN = 'PH'

*

    • HIERARCHY_HEADER =

    • INITIAL_HEADER_WIDTH =

    • LIST_ITEM_HEADER =

  • MULTIPLE_SELECTION = 'X'

    • ITEM_SELECTION = STREE_FALSE

    • SUPPRESS_NODE_ICON = STREE_FALSE

    • SUPPRESS_FOLDER_ICON = STREE_FALSE

    • CALLBACK_PROGRAM =

    • CALLBACK_ITEM_DISPLAY =

    • COLOR_MAPPING =

  • TYPE_MAPPING = type_mapping

    • IMPORTING

    • SUBSCREEN_PROGRAM =

    • SUBSCREEN_DYNNR =

    • EXCEPTIONS

    • NOT_AVAILABLE = 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.

*

*CALL FUNCTION 'RS_TREE_SET_CURRENT_LAYOUT'

    • EXPORTING

    • CURSOR_COLUMN = 3

    • CURSOR_LINE = 2

    • FIRST_NODE = 1

    • FIRST_NODE_TYPE = ' '

    • LIST_COLUMN = 1

    • LIST_LINE = 1

    • LAYOUT_MODE = STREE_LAYOUT_NORMAL

    • IMPORTING

    • INCONSISTENT_LAYOUT =

    • TABLES

    • LAYOUT =

  • .

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'

EXPORTING

  • CALLBACK_PROGRAM =

  • CALLBACK_USER_COMMAND =

  • CALLBACK_TEXT_DISPLAY =

  • CALLBACK_MOREINFO_DISPLAY =

  • CALLBACK_COLOR_DISPLAY =

  • CALLBACK_TOP_OF_PAGE =

  • CALLBACK_GUI_STATUS =

  • CALLBACK_CONTEXT_MENU =

  • STATUS = 'IMPLICIT'

  • CHECK_DUPLICATE_NAME = '1'

  • COLOR_OF_NODE = '4'

  • COLOR_OF_MARK = '3'

  • COLOR_OF_LINK = '1'

  • COLOR_OF_MATCH = '5'

  • LOWER_CASE_SENSITIVE = ' '

  • MODIFICATION_LOG = ' '

  • NODE_LENGTH = 30

  • TEXT_LENGTH = 75

  • TEXT_LENGTH1 = 0

  • TEXT_LENGTH2 = 0

  • RETURN_MARKED_SUBTREE = ' '

  • SCREEN_START_COLUMN = 0

  • SCREEN_START_LINE = 0

  • SCREEN_END_COLUMN = 0

  • SCREEN_END_LINE = 0

  • SUPPRESS_NODE_OUTPUT = ' '

  • LAYOUT_MODE = ' '

  • USE_CONTROL = STREE_USE_LIST

USE_CONTROL = 'L'.

  • IMPORTING

*----


hey and dont forget to award, if it was worth

cheers,

Aditya.

9 REPLIES 9

Former Member
0 Kudos
185

Hi narendiran,

1. Its quite simple.

2. Basically there are TWO FMs,

which do the job.

3. just copy paste in new program

and u will know the whole logic.

4.

REPORT abc.

DATA : tr LIKE TABLE OF snodetext WITH HEADER LINE.

*----


data

tr-id = '1'.

tr-tlevel = 1.

tr-name = 'amit'.

APPEND tr.

tr-id = '2'.

tr-tlevel = 2.

tr-name = 'mittal'.

APPEND tr.

*----


display

CALL FUNCTION 'RS_TREE_CONSTRUCT'

TABLES

nodetab = tr

EXCEPTIONS

tree_failure = 1

OTHERS = 4.

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'

.

regards,

amit m.

0 Kudos
185

hi amit

it worked, but i need to implement trees that are interactive i need to click/double click on a node and the nodes under it have to expand.

can you plz help me out?

0 Kudos
185

Hi,

You need to use classes. then you can do things like double/single exapnd etc.

check this demo example <b>SAPTLIST_TREE_CONTROL_DEMO</b>

regards

Vjay

0 Kudos
185

Hi Naren,

It is better to go in for classes.

One of the classes are CL_SIMPLE_TREE_CONTROL.

Try the transaction code DWDM and you can get some useful programs that will suit your needs.

If you can give me your mail-id I can send you one of my programs on the tree control.

Regards,

Sylendra.

0 Kudos
185

hi

i am trying to implement the tree with interactions like double click in classical list, plz can you tell me wher i can find such examples.

0 Kudos
185

Hi Narendran,

If you see this example <b>SAPTLIST_TREE_CONTROL_DEMO</b>

you can find double click, node expand, interactive tree list. this is an example on interactive tree report.

Check it

Regards

Vjay

0 Kudos
185

Hello Narendiran,

you can implement the node double click or single click (hotspot)

here are the code for the same.


DATA: itab LIKE TABLE OF snodetext WITH KEY id,
wa LIKE snodetext.
wa-type = 'ROOT'. " 1st node of the tree
wa-color = 3. " different attributes
wa-tlevel = 1.
wa-text = 'ROOT'.
wa-tlength = STRLEN( gd_nodes-text ).
APPEND wa TO itab.
CLEAR itab.

wa-type = 'ROOT'. "parent 
wa-color = 3.
wa-tlevel = 2.

wa-text = 'CHILD1'.
wa-kind = 'I'.
wa-tlength = 2 .
wa-tcolor = 0.

APPEND wa TO itab.
CLEAR itab.

* add all the nodes required for the list tree display to this internal table
* constructing the tree by calling the using the function *and using itab internal table
CALL FUNCTION 'RS_TREE_CONSTRUCT'
EXPORTING
insert_id = '000000'
relationship = ' '
TABLES
nodetab = itab
EXCEPTIONS
tree_failure = 1
id_not_found = 2
wrong_relationship = 3
OTHERS = 4.

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = sy-repid
* callback_user_command = 'USER_COMMAND'
* callback_top_of_page = 'TOP-OF-PAGE'
* callback_gui_status = 'SET_GUI'
* text_length1 = 80
EXCEPTIONS
OTHERS = 1.

* the parameter user_command specifies does the event handling part.

FORM user_command TABLES pt_nodes STRUCTURE seucom
                   USING pv_command TYPE c
                CHANGING pv_exit TYPE c
                         pv_list_refresh TYPE c.

case sy-ucomm.
   WHEN 'TRPI'.
   GET CURSOR FIELD field.
     CASE field.
        WHEN 'NODE'.
           NODE_TEXT= pt_nodes-text1.
* EXECUTE the operation as desired.
    endcase  .
endcase.
endform.

the form statement USER_COMMAND is very important as it has certain parameters and pt_nodes will contain the node_text from 1 to 9 of a particular clicked node.

i hope you find this answer useful.

get back to me if you have any doubts on this.

regards,

Kinshuk Saxena

Former Member
0 Kudos
185

Hi,

Refer Tcode DWDM.

Try F4 on BCALV*TREE in se38.

Regards,

Gayathri

Message was edited by: Gayathri Hariharan

former_member184495
Active Contributor
0 Kudos
186

hi narendiran,

try this out, and understand.

*----


Type-pools : fibs,stree.

data : t_node type snodetext.

data : node_tab like t_node occurs 0 with header line.

clear : node_tab, node_tab[].

node_tab-type = 'T'.

node_tab-name = 'ROOT'.

node_tab-tlevel = '01'.

node_tab-nlength = '5'.

node_tab-color = '4'.

node_tab-text = 'Root Node'.

node_tab-tlength ='11'.

node_tab-tcolor = 5.

append node_tab.

clear node_tab.

node_tab-type = 'P'.

node_tab-name = 'SubRoot'.

node_tab-tlevel = '02'.

node_tab-nlength = '8'.

node_tab-color = '1'.

node_tab-text = 'Sub Root Node'.

node_tab-tlength ='13'.

node_tab-tcolor = 3.

append node_tab.

clear node_tab.

node_tab-type = 'P'.

node_tab-name = 'Child Node'.

node_tab-tlevel = '04'.

node_tab-nlength = '11'.

node_tab-color = '4'.

node_tab-tlength ='5'.

node_tab-tcolor = 10.

append node_tab.

clear node_tab.

CALL FUNCTION 'RS_TREE_CONSTRUCT'

  • EXPORTING

  • INSERT_ID = '000000'

  • RELATIONSHIP = ' '

  • LOG =

TABLES

NODETAB = node_tab

  • EXCEPTIONS

  • TREE_FAILURE = 1

  • ID_NOT_FOUND = 2

  • WRONG_RELATIONSHIP = 3

  • OTHERS = 4

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

DATA: type_mapping TYPE stree_ctl_type_mapping_tab.

DATA: wa_type TYPE stree_ctl_type_mapping.

CLEAR: type_mapping[].

wa_type-type = 'A'.

wa_type-icon = '@BL@'.

APPEND wa_type TO type_mapping.

*CALL FUNCTION 'RS_TREE_CONTROL_PREPARE'

  • EXPORTING

    • CONTROL_PATTERN = STREE_CTL_GENERIC

  • CONTROL_PATTERN = 'PH'

*

    • HIERARCHY_HEADER =

    • INITIAL_HEADER_WIDTH =

    • LIST_ITEM_HEADER =

  • MULTIPLE_SELECTION = 'X'

    • ITEM_SELECTION = STREE_FALSE

    • SUPPRESS_NODE_ICON = STREE_FALSE

    • SUPPRESS_FOLDER_ICON = STREE_FALSE

    • CALLBACK_PROGRAM =

    • CALLBACK_ITEM_DISPLAY =

    • COLOR_MAPPING =

  • TYPE_MAPPING = type_mapping

    • IMPORTING

    • SUBSCREEN_PROGRAM =

    • SUBSCREEN_DYNNR =

    • EXCEPTIONS

    • NOT_AVAILABLE = 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.

*

*CALL FUNCTION 'RS_TREE_SET_CURRENT_LAYOUT'

    • EXPORTING

    • CURSOR_COLUMN = 3

    • CURSOR_LINE = 2

    • FIRST_NODE = 1

    • FIRST_NODE_TYPE = ' '

    • LIST_COLUMN = 1

    • LIST_LINE = 1

    • LAYOUT_MODE = STREE_LAYOUT_NORMAL

    • IMPORTING

    • INCONSISTENT_LAYOUT =

    • TABLES

    • LAYOUT =

  • .

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'

EXPORTING

  • CALLBACK_PROGRAM =

  • CALLBACK_USER_COMMAND =

  • CALLBACK_TEXT_DISPLAY =

  • CALLBACK_MOREINFO_DISPLAY =

  • CALLBACK_COLOR_DISPLAY =

  • CALLBACK_TOP_OF_PAGE =

  • CALLBACK_GUI_STATUS =

  • CALLBACK_CONTEXT_MENU =

  • STATUS = 'IMPLICIT'

  • CHECK_DUPLICATE_NAME = '1'

  • COLOR_OF_NODE = '4'

  • COLOR_OF_MARK = '3'

  • COLOR_OF_LINK = '1'

  • COLOR_OF_MATCH = '5'

  • LOWER_CASE_SENSITIVE = ' '

  • MODIFICATION_LOG = ' '

  • NODE_LENGTH = 30

  • TEXT_LENGTH = 75

  • TEXT_LENGTH1 = 0

  • TEXT_LENGTH2 = 0

  • RETURN_MARKED_SUBTREE = ' '

  • SCREEN_START_COLUMN = 0

  • SCREEN_START_LINE = 0

  • SCREEN_END_COLUMN = 0

  • SCREEN_END_LINE = 0

  • SUPPRESS_NODE_OUTPUT = ' '

  • LAYOUT_MODE = ' '

  • USE_CONTROL = STREE_USE_LIST

USE_CONTROL = 'L'.

  • IMPORTING

*----


hey and dont forget to award, if it was worth

cheers,

Aditya.