cancel
Showing results for 
Search instead for 
Did you mean: 

Navigate to a "sub node"

Former Member
0 Kudos

Hi Web-Dynpro experts,

I have an easy question for you:

How can i navigate to a "sub node" of the context?

Example:

context -> folder -> file

Navigation to "folder":

 
* navigation via lead selection
  NODE_INPUT = WD_CONTEXT->GET_CHILD_NODE( NAME = IF_VIEW=>WDCTX_FOLDER).

* get element via lead selection
  ELEM_INPUT = NODE_INPUT->GET_ELEMENT( ).

But how can i navigate to the sub node "file" ?

Many thanks in advance!

Regards,

Ludwig

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check this bit of code.

data :    l_subnode                 type ref to if_wd_context_node,
          l_subnodedata             type if_view=>element_folder.

 l_subnode = l_node->get_child_node( index = sy-tabix name = 'file' ).

l_subnodedata-att1 = 'ur data'.

l_subnode->bind_structure( l_subnodedata ).

Thanks.

Edited by: Viji on Mar 18, 2008 11:25 AM

Former Member
0 Kudos

Thanks for your quick answer but i want to do a "get_attribute":

 
 data :    l_subnode                 type ref to if_wd_context_node,
          l_subnodedata             type if_cockpit=>element_folder.

*          l_node = wd_context ?
 l_subnode = WD_CONTEXT->get_child_node( index = sy-tabix name = 'file' ).
 
l_subnodedata-att1 = 'ur data'. " ??????????
 
l_subnode->bind_structure( l_subnodedata ).

 l_subnode->GET_ATTRIBUTE(
   EXPORTING
     NAME = `fieldname`
   IMPORTING
     VALUE = lf_fieldname ).

Thanks

former_member515618
Active Participant
0 Kudos

Hi Ludwig,

Do the following:

NODE_INPUT = WD_CONTEXT->GET_CHILD_NODE( NAME = IF_VIEW=>WDCTX_FOLDER).

NODE_INPUT = NODE_INPUT->GET_CHILD_NODE( NAME = IF_VIEW=>WDCTX_FILE).

lo_element = NODE_INPUT->get_element( ).

lo_element->GET_ATTRIBUTE(

EXPORTING

NAME = `fieldname`

IMPORTING

VALUE = lf_fieldname ).

Regards,

Sravan Varagani

Former Member
0 Kudos

Hi,

for that you can use code wizard.

Check this auto genareted code.

Here node name is "Details" and sub node name is "changes".

Attribute name is old_value_string.

DATA:
    node_changes                        TYPE REF TO if_wd_context_node,
    node_details                        TYPE REF TO if_wd_context_node,
    elem_details                        TYPE REF TO if_wd_context_element,
    stru_details                        TYPE if_userlog=>element_details ,
    item_old_value_string               LIKE stru_details-old_value_string.
* navigate from <CONTEXT> to <CHANGES> via lead selection
  node_changes = wd_context->get_child_node( name = if_userlog=>wdctx_changes ).

* @TODO handle not set lead selection
  IF ( node_changes IS INITIAL ).
  ENDIF.

* navigate from <CHANGES> to <DETAILS> via lead selection
  node_details = node_changes->get_child_node( name = if_userlog=>wdctx_details ).

* alternative navigation via index
* Node_Details = Node_Changes->get_Child_Node(
*   Name = `DETAILS` Index = 1 ).
* @TODO handle non existant child
* if ( Node_Details is initial ).
* endif.

* get element via lead selection
  elem_details = node_details->get_element(  ).

* get single attribute
  elem_details->get_attribute(
    EXPORTING
      name =  `OLD_VALUE_STRING`
    IMPORTING
      value = item_old_value_string ).

Thanks.

Former Member
0 Kudos

Hi @ all,

So many solutions - great!

Sravan's solution works very nice and the solution from Viji with the code wizard is very easy. Thanks a lot

Best regards,

Ludwig

Answers (2)

Answers (2)

Former Member
0 Kudos

hi

data: node1 type ref to if_wd_context_node,

node2 type ref to if_wd_context_node.

node1 = wd_context->get_child_node( wd_this->wdctx_folder ).

node2 = node1->get_child_node( wd_this->wdctx_file ).

regards,

janakiram.

former_member515618
Active Participant
0 Kudos

Hi,

NODE_INPUT = WD_CONTEXT->GET_CHILD_NODE( NAME = IF_VIEW=>WDCTX_FOLDER).

NODE_INPUT = NODE_INPUT->GET_CHILD_NODE( NAME = IF_VIEW=>WDCTX_FILE).

Now node NODE_INPUT has reference to the child node 'FILE' which is a sub-folder in node 'FOLDER'.

General way is to use code wizard, select the sub node directly and get the reference.

Regards,

Sravan Varagani