‎2008 Mar 17 10:02 PM
Hello,
I created a simple tree and now I have to add a toolbar to this tree.
How can I do this?
Best regards & Thanks in advance
Alberto
‎2008 Mar 18 3:10 AM
A Simple Tree Program:
*******start of code
REPORT Ztree_TEST_PGM.
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 = 'Earth'.
node_tab-tlevel = '01'.
node_tab-nlength = '5'.
node_tab-color = '4'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 3.
append node_tab.
clear node_tab.
node_tab-type = 'P'.
node_tab-name = 'Europe'.
node_tab-tlevel = '02'.
node_tab-nlength = '6'.
node_tab-color = '1'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 4.
append node_tab.
clear node_tab.
node_tab-type = 'P'.
node_tab-name = 'Germany'.
node_tab-tlevel = '03'.
node_tab-nlength = '7'.
node_tab-color = '4'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 4.
append node_tab.
clear node_tab.
node_tab-type = 'P'.
node_tab-name = 'Berlin'.
node_tab-tlevel = '04'.
node_tab-nlength = '6'.
node_tab-color = '4'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 3.
append node_tab.
clear node_tab.
node_tab-type = 'P'.
node_tab-name = 'Asia'.
node_tab-tlevel = '02'.
node_tab-nlength = '4'.
node_tab-color = '1'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 3.
append node_tab.
clear node_tab.
node_tab-type = 'P'.
node_tab-name = 'India'.
node_tab-tlevel = '03-'.
node_tab-nlength = '5'.
node_tab-color = '1'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 3.
append node_tab.
clear node_tab.
node_tab-type = 'P'.
node_tab-name = 'Bombay'.
node_tab-tlevel = '04-'.
node_tab-nlength = '6'.
node_tab-color = '1'.
node_tab-text = 'Hello'.
node_tab-tlength ='5'.
node_tab-tcolor = 3.
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
F15 =
**********end of program .
A list of other function modules that can also be used to construct tree reports:
SEUT, Hierarchy framework
RS_TREE_ADD_NODE Insert nodes
RS_TREE_AUTOMATIC_REFRESH
RS_TREE_COMPRESS Hide subtree(s)
RS_TREE_CONSTRUCT Construct new hierarchy or insert subtree
RS_TREE_CONTROL_PREPARE
RS_TREE_CREATE Create hierarchy
RS_TREE_DELETE_NODE Delete node with associated sub-tree
RS_TREE_EXPAND Expand subtree
RS_TREE_GET_CURRENT_LAYOUT Get layout information for displayed hierarchy
RS_TREE_GET_CURRENT_NODE Get node at which cursor is positioned
RS_TREE_GET_CURRENT_ROOT Get current root node
RS_TREE_GET_CURRENT_TREE Get structure information for displayed hierarchy
RS_TREE_GET_INPUT Get entires from input fields
RS_TREE_GET_MARKED_NODES Get selected nodes
RS_TREE_GET_MODIFICATION_LOG Get change log for hierarchy
RS_TREE_GET_NODE Get nodes for specified ID
RS_TREE_GET_NODE_BY_NAME Get node for specified node name
RS_TREE_GET_PREDECESSOR Get preceding node
RS_TREE_GET_SEARCHSTRING Get last search strinng
RS_TREE_LIST Simulate hierarchy or subtree display
RS_TREE_LIST_DISPLAY Display hierarchy
RS_TREE_LIST_DISPLAY Display hierarchy
RS_TREE_MODIFY_NODE
RS_TREE_MOVE Reassign node with subtree
RS_TREE_POP Get hierarchy from the stack and restore
RS_TREE_PUSH Place hierarchy on the stack
RS_TREE_RESET_LOCK Deselect node
RS_TREE_SET_CURRENT_LAYOUT Set layout with marked cursor position
RS_TREE_SET_CURRENT_TREE Set other hierarchy
RS_TREE_SET_LOCK Select node
RS_TREE_SET_NODE Change Nodes
RS_TREE_SET_SCROLL_POS Position node at the beginning of the page
RS_TREE_SLEEP
RS_TREE_SORT_CHILDREN
Reward points if useful
‎2008 Mar 18 3:11 AM
simple tree program
REPORT ZVVMUR12 .
TABLES: KNVH.
TYPES: BEGIN OF WORKTYPE,
LEVEL(2),
HKUNNR LIKE KNVH-KUNNR,
KUNNR LIKE KNVH-HKUNNR,
END OF WORKTYPE.
DATA: IT_KNVH TYPE TABLE OF WORKTYPE,
WA_KNVH LIKE LINE OF IT_KNVH,
IT_TEMP TYPE TABLE OF WORKTYPE,
WA_TEMP LIKE LINE OF IT_TEMP,
IT_WORK TYPE TABLE OF WORKTYPE,
WA_WORK LIKE LINE OF IT_WORK.
DATA : BEGIN OF IT_NODES OCCURS 0.
INCLUDE STRUCTURE SNODETEXT.
DATA : END OF IT_NODES.
CONSTANTS: NUMBER_OF_LEVELS TYPE I VALUE 6.
PARAMETER: P_HKUNNR LIKE KNVH-HKUNNR.
START-OF-SELECTION.
Parent = 1. hierarchy node
WA_TEMP-KUNNR = P_HKUNNR.
APPEND WA_TEMP TO IT_TEMP.
WA_WORK-KUNNR = WA_TEMP-KUNNR.
WA_WORK-LEVEL = 1.
APPEND WA_WORK TO IT_WORK.
Reading customer hierarchy (max. 6 level)
DO NUMBER_OF_LEVELS TIMES.
CHECK NOT IT_TEMP IS INITIAL.
SELECT KUNNR HKUNNR
FROM KNVH
INTO CORRESPONDING FIELDS OF TABLE IT_KNVH
FOR ALL ENTRIES IN IT_TEMP
WHERE HKUNNR = IT_TEMP-KUNNR.
LOOP AT IT_KNVH INTO WA_KNVH.
WA_KNVH-LEVEL = SY-INDEX + 1.
APPEND WA_KNVH TO IT_WORK.
ENDLOOP.
IT_TEMP] = IT_KNVH[.
ENDDO.
Hierarchy nodes -> tree control
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 1.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 2 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 3 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 4 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 5 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 6 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Making the tree control
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
NODETAB = IT_NODES
EXCEPTIONS
TREE_FAILURE = 1.
Display the tree control
DATA : F15 TYPE C.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
CALLBACK_PROGRAM = SY-REPID
IMPORTING
F15 = F15 .
FORM MAKE_NODE.
IT_NODES-NAME = WA_WORK-KUNNR.
IT_NODES-COLOR = 1.
IT_NODES-INTENSIV = 1.
IT_NODES-TEXT = WA_WORK-KUNNR.
IT_NODES-TLENGTH = 16.
IT_NODES-TLEVEL = WA_WORK-LEVEL.
IT_NODES-TCOLOR = 1.
IT_NODES-TINTENSIV = 1.
APPEND IT_NODES.
ENDFORM.
http://www.sapdev.co.uk/reporting/alv/alvtree/simpletree_basic.htm
Reward points..
‎2008 Mar 18 12:07 PM
Hi,
my question wasn't how to create a tree but to create a toolbar for a tree.
Is this possible?
Best regards
Alberto
‎2008 Mar 19 7:40 AM
Hi,
Assuming that you have used the simple tree model, i.e. class CL_SIMPLE_TREE_MODEL, you have to generate the toolbar on a separate container.
One of the approaches could be as follows:
-> Use a splitter container e.g. S1 to generate 2 containers, say C1 & C2( both ref to CL_GUI_CONTAINER).
-> On one of the containers C1, create a toolbar as follows
CREATE OBJECT <inst_of_CL_GUI_TOOLBAR>
EXPORTING parent = <C1>.-> On another container you can create your tree.
Please note that the tree & toolbar are not linked implicitly & you have handle in your code the toolbar functions with respect to the tree processing.