Friday, November 23, 2007

sap abap program for How to Create Tree Control

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

No comments:

Blog Archive