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

Output list in tree format!!!

Former Member
0 Likes
1,650

Hi,

I want ouput in tree format. In the basic nodes, I want customer wise sales. Then if i expand that node then gives subnodes like <b>'finished goods' and 'trading goods'</b> and so on. I want to know the procedure to achieve this task.

Regards,

Bhavin

Hi,

I want ouput in tree format. In the basic nodes, I want customer wise sales. Then if i expand that node then gives subnodes like <b>'finished goods' and 'trading goods'</b> and so on. I want to know the procedure to achieve this task.

Regards,

Bhavin

7 REPLIES 7
Read only

athavanraja
Active Contributor
0 Likes
1,186

check out these demo programs

SAPTLIST_TREE_CONTROL_DEMO

SAPCOLUMN_TREE_CONTROL_DEMO

SAPSIMPLE_TREE_CONTROL_DEMO

Regards

Raja

Read only

0 Likes
1,186

also check out this program. (ALV Tree)

BCALV_TREE_DEMO

Regards

Raja

Read only

Former Member
0 Likes
1,186

This demo programs are bit tough to understand. Can you tell me some like from where i can get material. So that i can get concepts.

Regards,

Bhavin

Read only

0 Likes
1,186

for your case BCALV_TREE_DEMO will best suit the requirement.

Here is the online documentation explaining all the tree control models i had mentioned before.

http://help.sap.com/saphelp_erp2005/helpdata/en/b7/147a36c70d2354e10000009b38f839/frameset.htm

Regards

Raja

Read only

Former Member
0 Likes
1,186

Hi,

U can use Transaction Code ->DWDM for more examples related to Tree Column

the list of fn modules that can 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

A sample tree pgm.

*******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           .                     .

Refer this link also.

http://www.kabai.com/abaps/q.htm

Regards,

Gayathri

Read only

Former Member
0 Likes
1,186

HI bhavin,

1. RS_TREE_CONSTRUCT

RS_TREE_LIST_DISPLAY

2. The above two are the basic

FMs to achieve tree display.

3. use like this.

DATA : tr LIKE TABLE OF snodetext WITH HEADER LINE .

CALL FUNCTION 'RS_TREE_CONSTRUCT'

TABLES

nodetab = tr

EXCEPTIONS

tree_failure = 1

OTHERS = 4.

4. tr

populate your tree data into it.

5. just copy paste in new program.

it will display

amit

|

|

-


mittal

6.

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.

Message was edited by: Amit Mittal

Read only

Former Member