cancel
Showing results for 
Search instead for 
Did you mean: 

Use Tree Recursive in web dynpro

Former Member
0 Kudos

someone has never used a tree recursive node and if as it has organized the context ?

you have some example of plan on a tree using one web dynpro?

Thanks in advance payment

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Marco,

I am afraid I do not understand your question. Could you please clarify?

Best regards, Karin

Former Member
0 Kudos

In my project they arrive me of the data from sap and I must put them in a graphical tree with web dynrpo.

it must be a recursive node but not there are examples or explanations on this.....one of my problems is to a context menu of tre recursive node ....a child is not relationship with a context why? can you help me?

you more know something on this type than tree?

Former Member
0 Kudos

Code Example for Using a Recursive Node

The example below shows the Data Binding of a Tree UI Element to a context structure whose hierarchical structure is not known at design time and for which, therefore, a fixed number of levels cannot be determined at design time. The context provides a special node for this case, the recursive node.

Prerequisites

You created a Web Dypro application and you created the view ?RecursiveTree? within a Web Dynpro Component, which you can include into a Tree UI Element and its subelement TreeNodeType.

Procedure

Create a tree in the ?RecursiveTree? view as follows:

       1. Add the tree UI element with the ID Tree.

       2. Add the node element of type TreeNodeType with the ID Node.

Context Creation:

The context that provides the data is created as follows:

       1. Creating the singleton node TreeNode with cardinality 0..n.

       2. Creating the context attribute text.

       3. Creating the recursive node Child.

You can also create the context structure before creating the view. In this case, you can already bind the bindable properties of the UI element to the context nodes and context attributes while inserting the UI elements.

Data Binding

To display the data in a UI element, the appropriate properties of the UI element must be bound to the context nodes.

       1. To do this, select the Layout tab page and edit the properties of the UI element Tree with the ID Tree and its subelement Node.

       2. Navigate to the dataSource property and choose in the Properties window. The button appears. It enables you to access the Context Viewer dialog box.

       3. Select the desired context node.

       4. Choose OK.

       5. The UI element property is now bound to a context element. The following table lists the main data binding relationships of the Tree example. The associated TreeNodeType subelement Node is bound to the corresponding context node in the same way.

Object                   Object ID Data Binding Path Within the Context Structure

Tree                       Tree dataSource property ® RecursiveTree.TreeNode

                                                  value node TreeNode

TreeNodeType        Node dataSource property ® RecursiveTree.TreeNode

                                                  value node TreeNode

Filling the Context with Data

The wdDoInit method in the controller implementation provides a means of filling the context of a view with data. The method is a Hook method, whose source code is executed when the view controller is initialized.

       1. To do this, go to the Implementation tab page. This selection generates the controller implementation.

       2. The source code that is called when initializing the controller can be inserted into the user coding area that starts with the character string //@@begin wdDoInit() and ends with the character string //@@end. The source code in the wdDoInit method for this example is:

-

-


public void wdDoInit()

  {

    //@@begin wdDoInit()

    IPrivateRecursiveTree.ITreeNodeElement level1element;

    for (int i = 0; i < 2; i++) {

      level1element = wdContext.createTreeNodeElement();

      level1element.setText("Node " + i);

      wdContext.nodeTreeNode().addElement(level1element);

      for (int j = 0; j < 4; j++) {

         IPrivateRecursiveTree.ITreeNodeElement level2element = level1element.nodeChild().createTreeNodeElement();

            level2element.setText("SubNode " + i + "." + j);

            level1element.nodeChild().addElement(level2element);

          for (int k = 0; k < 6; k++) {

             IPrivateRecursiveTree.ITreeNodeElement level3element = level2element.nodeChild().createTreeNodeElement();

                level3element.setText("SubNode " + i + "." + j + "." + k);

                level2element.nodeChild().addElement(level3element);

              for (int l = 0; l < 8; l++) {

                 IPrivateRecursiveTree.ITreeNodeElement level4element = level3element.nodeChild().createTreeNodeElement();

                    level4element.setText("SubNode " + i + "." + j + "." + k + "." + l);

                    level3element.nodeChild().addElement(level4element);

               }

        }

      }

    }

    //@@end

  }

-

-


Calling the Web Application

Before you can call the Web application, you must build the corresponding Web Dynpro project and install the Web application on the SAPJ2EE Engine. You use a Web address to call the Web application in the browser.

Result

The resulting tree displays three customers, customer no:0 to customer no:2, each of them containing:

·        Three purchase orders (0:0 to 0:2) with five purchase items (IDs 0:1:0 to 0:1:4)

·        Three orders (0:0 to 0:2) with five items (IDs 0:1:0 to 0:1:4)

Former Member
0 Kudos

Hi Marco,

Please let me know, if that was helpful for you.

Best regards, Karin

Former Member
0 Kudos

Hello Katrin, I would like to ask you an opinion about a problem similar to the example you sent me.

They (my colleagues) have to create a navigation tree that has to be built dynamically during the running time, and that navigation tree

should use data from a SAP R/3 (something like a BOM, or a work breakdown

structure). That because we need to understand how to structure the SAP

table, and how to build context and model binding in web dynpro.

As you would behave yourself with a case of the sort in Netweaver.

Thank you for your help, regards and have a nice weekend

Former Member
0 Kudos

Hi Marco,

There will be a reference guide available very soon. Please stay tuned. I will let you know about it as soon as it is available.

Best regards,

Karin

Former Member
0 Kudos

Karin and Marco,

I hope I am not hijacking this thread as my question is concerning recursive trees as well and I thought adding my question to this thread might be useful to some. I am currently working from the SAP ABAP WD book and under the recursive trees example it is illustrating how to build a menu based on the mime repository. The two coding areas I have completed are below (as well as my question)

METHOD wddoinit .

  • Build the initial root element /sap

DATA lr_current_node TYPE REF TO if_wd_context_node.

DATA lr_current_element TYPE REF TO if_wd_context_element.

lr_current_node = wd_context->get_child_node( 'CONTENT' ).

lr_current_element = lr_current_node->create_element( ).

lr_current_element->set_attribute( name = 'NAME'

value = 'SAP' ).

lr_current_element->set_attribute( name = 'PATH'

value = '/sap' ).

lr_current_node->bind_element( lr_current_element ).

lr_current_node->set_lead_selection( lr_current_element ).

ENDMETHOD.

METHOD onactiondo_load .

DATA:

lr_element TYPE REF TO if_wd_context_element,

lr_node TYPE REF TO if_wd_context_node,

lr_mime_api TYPE REF TO if_mr_api,

lt_path_entries TYPE string_table,

lv_index TYPE sytabix,

lv_is_folder TYPE abap_bool,

ls_io TYPE skwf_io,

lt_ios TYPE skwf_ios,

lv_url TYPE skwf_url,

lv_path TYPE string,

lv_children_loaded TYPE string,

ls_mime_entry TYPE if_v_default=>element_content.

lr_node = wd_context->get_child_node( name = if_v_default=>wdctx_content ).

lr_element = lr_node->get_element( ).

  • Avoid redundant loading of data

lr_element->get_attribute( EXPORTING name = 'CHILDREN_LOADED'

IMPORTING value = lv_children_loaded ).

CHECK lv_children_loaded = abap_false.

lr_element->set_attribute( EXPORTING name = 'CHILDREN_LOADED'

value = abap_true ).

  • Create children elements

lr_element->get_attribute( EXPORTING name = 'PATH'

IMPORTING value = lv_path ).

lr_mime_api = cl_mime_repository_api=>if_mr_api~get_api( ).

lr_mime_api->get_io_for_url( EXPORTING i_url = lv_path

IMPORTING e_loio = ls_io ).

  • Get children

CALL METHOD cl_skwf_folder_util=>ios_attach_get

EXPORTING

folder = ls_io

iotypeacc = ' '

x_prefetch_properties = abap_true

IMPORTING

ios = lt_ios.

LOOP AT lt_ios INTO ls_io.

CALL FUNCTION 'SKWF_NMSPC_IO_ADDRESS_GET'

EXPORTING

io = ls_io

IMPORTING

url = lv_url.

ls_mime_entry-path = lv_url.

READ TABLE lt_path_entries INDEX lv_index INTO ls_mime_entry-name.

  • Determine type of element

CALL METHOD lr_mime_api->properties

EXPORTING

i_url = ls_mime_entry-path

IMPORTING

e_is_folder = lv_is_folder.

IF lv_is_folder = abap_true.

  • Create folder element

lr_node = lr_element->get_child_node( 'MIMECONTENT' ).

ELSE.

  • Create a file element

lr_node = lr_element->get_child_node( 'MIMEITEM' ).

ENDIF.

lr_node->bind_structure( new_item = ls_mime_entry

set_initial_elements = abap_false ).

ENDLOOP.

ENDMETHOD.

The problem is that the code above seems to only semi-work. As you can see:

<a href="http://i12.photobucket.com/albums/a215/hebere/test.gif"></a>

the structure is not completing. The MIME repository is many levels deep. I have been doing some searching on the forums looking for similar examples and have been unsuccessful so far. Do you see any glaring errors or some logic that I am missing out on?

This is probably not the best example to start on since it is utilizing some functions etc that I am unfamiliar with.

Thanks in advance!

--rob

Message was edited by:

Robert Baggett