cancel
Showing results for 
Search instead for 
Did you mean: 

How to create Hierarchy Tree Node structure?

Former Member
0 Kudos

Hi experts,

I want to know how to create a tree with kind of below Structure:

Root A

NodeA1

ITEMA1_IT1

ITEMA1_IT2

ITEMA1_IT3

NodeA2

ITEMA2_IT1

ITEMA2_IT2

NodeA3

ITEMA3_IT1

ITEMA3_IT2

ITEMA3_IT3

ITEMA3_IT4

So when i click on Root A it shows me, NODEA1, NODEA2 & NODEA3....

when further i click on NODEA1, it shows me items like ITEMA1_IT1,ITEMA1_IT2, ITEMA1_IT3.

when further i click on NODEA2, it shows me items like ITEMA2_IT1,ITEMA2_IT2.

SO item will get loaded when i click on perticular node.

how its possible.

I have gone through SDN so many threads, bt i didn't get exactly for webdynpro ABAP.

Please guide me for the same.

Thanks ,

Saurin Shah

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

you can create the tree you wanted as follows:

1) create a node under your context say "root_node" with cardinality 1..1

2) now create an attribute under it called "text" with type string.

3) now create three nodes under this "root_node" called nodeA1 nodeA2 and nodeA3 with cardinality 0..n

4) now under nodeA1 , nodeA2 and nodeA3 create an attribute called "text" with type string...so each node will have one attribute called "text" of type string...

5) now create a node under nodeA1 called "itemA1" with cardinlity 0..n

6) now create an attribute called "text" of type string under this node "itemA"...

7) repeat step 5 and 6 for the other two nodes...nodeA2 and nodeA3

😎 now create six supply functionsthese functions will supply the text values for your nodes-

I created like this:

FILL_ITEM1

FILL_ITEM2

FILL_ITEM3

FILL_NODEA1

FILL_NODEA2

FILL_NODEA3

******************************************************************************************************

Note:*******************my view is called MAIN******************

hence the coding is

data

lt_elements type if_main=>elements_nodea1.

if you view is called view1...than the data declaration would be

data

lt_elements type if_view1=>elements_nodea1.

*****************************************************************************************************

9) go to each node and assign the supply function respectively....you can assign this by going to context tab and selecting the node you want to assign the supply function to and just type in the name of the supply funciton or do the help for that field by clicking on the little square btn...

10) now we go the layout tab and put the tree ui on the layout....bind the datasource property to the context node "root_node"

and bind the rootText property to the attribute "text" of the root_node...

11) now right click on this tree ui element under the ROOTUIELEMENTCONTAINER and select "insert node type" ...a box will appear where you can see it has two types of node for you....one is tree_node_type and other one is tree_item_type...

create three nodes with tree_node_type with names "nodeA1" nodeA2 and nodeA3 and three with tree_item_type with names "itemA1" itemA2 and itemA3...

12) now bind all these node types and item types data sources and texts with corresponding nodes and attributes under your context...

so nodeA1datasource will get bind to context nodeA1 and itemA1 data source will get bind to itemA1 from context..and so on...

13) now in the wddoinit method: I setup the text for the root node.....

DATA lo_nd_root_node TYPE REF TO if_wd_context_node.

DATA lo_el_root_node TYPE REF TO if_wd_context_element.

DATA ls_root_node TYPE wd_this->element_root_node.

DATA lv_root_txt TYPE wd_this->element_root_node-root_txt.

  • navigate from <CONTEXT> to <ROOT_NODE> via lead selection

lo_nd_root_node = wd_context->get_child_node( name = wd_this->wdctx_root_node ).

  • get element via lead selection

lo_el_root_node = lo_nd_root_node->get_element( ).

  • @TODO fill attribute

lv_root_txt = 'Root Node'.

  • set single attribute

lo_el_root_node->set_attribute(

name = `ROOT_TXT`

value = lv_root_txt ).

hope this will give you the solution you are looking for...

Thanks...

AS...........

Former Member
0 Kudos

Hi,

you might want to look into this example: WDR_TEST_TREE

also...

http://caslanding/ECC60/helpdata/EN/21/ad884118aa1709e10000000a155106/frameset.htm

thanks...

AS....