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

Get CL_GUI_COLUMN_TREE nodes table

Former Member
0 Likes
1,440

Hello all,

I use a column tree to display an Organizational Unit. Several additional nodes are defined in a dictionary table Z* with entries:

parentID/parenttype/childID/childtype

500000000/O/SMITH/US

I try to use method add_nodes_and_items, but I need 'parent key' not 'parent ID' to add them (table node_table like treev_ntab).

How can I read node_key which corresponds to this parentID '500000000'?

Thanks in advance,

Cristina

Message was edited by: CT

Hello all,

I use a column tree to display an Organizational Unit. Several additional nodes are defined in a dictionary table Z* with entries:

parentID/parenttype/childID/childtype

500000000/O/SMITH/US

I try to use method add_nodes_and_items, but I need 'parent key' not 'parent ID' to add them (table node_table like treev_ntab).

How can I read node_key which corresponds to this parentID '500000000'?

Thanks in advance,

Cristina

Message was edited by: CT

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
864

Hello Cristina

You have to define the node keys yourself. Since you are using OrgManagement objects it is reasonable to use the object id as unique key for your nodes.

Have a look at the sample report <b>SAPCOLUMN_TREE_CONTROL_DEMO</b>. The nodes and items itabs are filled in routine <b>BUILD_NODE_AND_ITEM_TABLE</b>. Here is part of the coding that shows how to relate parent and child nodes:

[code]FORM BUILD_NODE_AND_ITEM_TABLE

USING

NODE_TABLE TYPE TREEV_NTAB

ITEM_TABLE TYPE ITEM_TABLE_TYPE.

DATA: NODE TYPE TREEV_NODE,

ITEM TYPE MTREEITM.

  • Build the node table.

  • Caution: The nodes are inserted into the tree according to the order

  • in which they occur in the table. In consequence, a node must not

  • must not occur in the node table before its parent node.

<b>*$Comment: You define the key of the node (here: root node)

  • You could use any name except of an object id

  • that will follow as child node!</b>

  • Node with key 'Root'

NODE-NODE_KEY = 'Root'. "#EC NOTEXT

" Key of the node

CLEAR NODE-RELATKEY. " Special case: A root node has no parent

CLEAR NODE-RELATSHIP. " node.

NODE-HIDDEN = ' '. " The node is visible,

NODE-DISABLED = ' '. " selectable,

NODE-ISFOLDER = 'X'. " a folder.

CLEAR NODE-N_IMAGE. " Folder-/ Leaf-Symbol in state "closed":

" use default.

CLEAR NODE-EXP_IMAGE. " Folder-/ Leaf-Symbol in state "open":

" use default

CLEAR NODE-EXPANDER. " see below.

APPEND NODE TO NODE_TABLE.

<b>*$Comment: here you would use the object id of your

  • organizational unit</b>

  • Node with key 'Child1'

NODE-NODE_KEY = 'Child1'. "#EC NOTEXT

" Key of the node

<b>*$Comment: if your parent node is an organizational unit

  • then node-relatkey = <objectID of OrgUnit></b>

" Node is inserted as child of the node with key 'Root'.

NODE-RELATKEY = 'Root'.

NODE-RELATSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD.

NODE-HIDDEN = ' '.

NODE-DISABLED = ' '.

NODE-ISFOLDER = 'X'.

CLEAR NODE-N_IMAGE.

CLEAR NODE-EXP_IMAGE.

NODE-EXPANDER = 'X'. " The node is marked with a '+', although

" it has no children. When the user clicks on the

" + to open the node, the event expand_nc is

" fired. The programmerr can

" add the children of the

" node within the event handler of the expand_nc

" event (see callback handle_expand_nc).

APPEND NODE TO NODE_TABLE.[/code]

Regards

Uwe

Read only

Former Member
0 Likes
864

Hi Cristina

Please check if following steps works:

1. Define your internal table with additional fields for Parent Node Key and Child Node Key, we need not necessarily use this for displaying.

2. While Creating each node either parent or child, update these with their nodekey.

3. If we do so, this can be used as reference at a later stage to manipulate the same.

I hope this might work.

Kind Regards

Eswar

Read only

0 Likes
864

Hello again,

I'm using function module OM_OOT_CREATE_TREE, so I can't access to tree creation.

CALL FUNCTION 'OM_OOT_CREATE_TREE'

EXPORTING

plvar = '01'

root_otype = 'O'

root_objid = lv_objid

pathid = 'SAP_AGNT'

............

IMPORTING

handle = e_handle

TABLES

column_headers = lt_columnheaders

CHANGING

registered_events = lt_events

EXCEPTIONS

root_not_found = 1

path_not_found = 2

OTHERS = 3.

Then, I call method e_handle->add_nodes_and_trees. For example, I nedd to add USER2 as child of USER1, so parent_id = "USER1" but I can't read <b>node_key</b> which requires 'node_table':

CALL METHOD e_handle->add_nodes_and_items

EXPORTING

node_table = gt_node_table

item_table = gt_item_table

item_table_structure_name = 'MTREEITM'

EXCEPTIONS

failed = 1

cntl_system_error = 2

error_in_tables = 3

dp_error = 4

table_structure_name_not_found = 5.

Thanks,

Cristina