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: 

Error is hierarchial ALV tree

Former Member
0 Kudos

hi,

I am trying to create a hierarchial alv tree using cl_gui_simple_tree. I am able to add nodes upto 2 level ( that is the root node and its childnodes). When i try to add nodes under the child nodes, i get a dump saying that "Cannot use a node of type leaf as parent"..For adding the node at third level, i used the

relatship as cl_gui_list_tree=>relat_last_child. Is it any problem with this ??

1 REPLY 1

Former Member
0 Kudos

HI,

Please try program 'SAPSIMPLE_TREE_CONTROL_DEMO', sample program of tree controls.

here's a piece of code:

add 1 to childnr.

concatenate 'child' childnr into childname.

NODE-NODE_KEY = childname.

NODE-ISFOLDER = 'X'.

NODE-EXPANDER = 'X'.

ITEM-NODE_KEY = childname.

move childname to vtab-childname.

add 1 to dateinr.

NODE-NODE_KEY = dateinr.

ITEM-NODE_KEY = node-node_key.

move dateinr to vtab-childname.

modify vtab from wa.

APPEND ITEM TO ITEM_TABLE.

APPEND NODE TO NODE_TABLE.

*Datum

clear item.

ITEM-NODE_KEY = NODE-NODE_KEY.

ITEM-ITEM_NAME = '2'.

ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.

ITEM-LENGTH = 10.

ITEM-USEBGCOLOR = 'X'.

ITEM-TEXT = vtab-datum.

APPEND ITEM TO ITEM_TABLE.

*Größe

clear item.

ITEM-NODE_KEY = NODE-NODE_KEY.

ITEM-ITEM_NAME = '3'.

ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.

ITEM-LENGTH = 10.

ITEM-USEBGCOLOR = 'X'.

ITEM-TEXT = vtab-len.

APPEND ITEM TO ITEM_TABLE.

*und los

CALL METHOD G_TREE->ADD_NODES_AND_ITEMS

EXPORTING

NODE_TABLE = NODE_TABLE

ITEM_TABLE = ITEM_TABLE

ITEM_TABLE_STRUCTURE_NAME = 'MTREEITM'

EXCEPTIONS

FAILED = 1

CNTL_SYSTEM_ERROR = 3

ERROR_IN_TABLES = 4

DP_ERROR = 5

TABLE_STRUCTURE_NAME_NOT_FOUND = 6.

IF SY-SUBRC <> 0.

MESSAGE A000.

ENDIF.

Regards,

Sankar