cancel
Showing results for 
Search instead for 
Did you mean: 

Context subnodes return null

Former Member
0 Kudos

Hi all,

I have been working for the last several days on this and can not figure it out. Here is what I am trying to accomplish. I have copied the context from the component controller to the context of the view. In the view I have created 2 nodes that are identical, one is mapped to the component controller context and the other is not, but bound to elements of the view. I want to be able to take the data from the mapped context filter the data and then pass what I want into the unmapped context. The problem I am running into is that I am having trouble accessing my subnode. I can get a reference to the node: context->node1 using both get_child_node and path_get_node, but when I try to create a reference to the subnode: context-node1-node2, which has the data I want displayed on the view, the reference is always returned null. The component I am working on was already in place, so I don't want to change the order of the nodes. Does anyone know why when I try to get a reference to the subnode I always get a null reference value? I tried creating a test web dynpro component and created a node with a subnode with data in it and had the same problem. Thank you for your time and help.

Michael

Accepted Solutions (0)

Answers (2)

Answers (2)

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

just wanted to confirm about how you are getting the reference for the node2... are you retrieving the reference of node2 in the same way like the one mentioned below


data lo_nd_node1 type ref to if_wd_context_node
data lo_nd_node2 type ref to if_wd_context_node
data lo_el_node1 type ref to if_wd_context_element


lo_nd_node1 = wd_context->get_child_node( 'NODE1' ).
lo_el_node1 = lo_nd_node1->get_element( ).

lo_nd_node2 = lo_el_node1->get_child_node( 'NODE2' ).


BR, Saravanan

Former Member
0 Kudos

This is what the context looks like:

Context

___I

___I--->NODE1

_________I

_________I--->SUBNODE

(Sorry I tried using spaces, but it kept realigning my text to the left, just ignore the underscores)

No, this is what I've been doing.


  DATA lo_nd_node TYPE REF TO if_wd_context_node.

  DATA lo_el_node TYPE REF TO if_wd_context_element.

* navigate from <CONTEXT> to <CAUTH_COMV_V> via lead selection
  lo_nd_node = wd_context->path_get_node( path = `NODE.SUBNODE` ).

* I have also tried this
  lo_nd_node = wd_context->get_child_node( name = `NODE1` ).
  lo_nd_node = lo_nd_node->get_child_node( name = `SUBNODE` ).

* get element via lead selection
  lo_el_ = lo_nd_->get_element( ).

Edited by: champion661 on Sep 7, 2011 5:07 PM

Former Member
0 Kudos

If i am not wrong you would have declared element reference to your subnode as

DATA lo_el_ TYPE REF TO if_wd_context_element.

Else Please declare it as above if you dint declare it , and change the statement below in your code:

lo_el_ = lo_nd_->get_element( ).

as

lo_el_ = lo_nd_node->get_element( ).

It will work now.Even if it is not getting path correctly in your code : code it normally as follows:-

DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

DATA lo_nd_node2 TYPE REF TO if_wd_context_node.

DATA lo_el_node2 TYPE REF TO if_wd_context_element.

DATA ls_node2 TYPE wd_this->element_node2.

lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

lo_nd_node2 = lo_nd_node1->get_child_node( name = wd_this->wdctx_node2 ).

lo_el_node2 = lo_nd_node2->get_element( ).

lo_el_node2->get_static_attributes( IMPORTING static_attributes = ls_node2 ).

In the above code, node 1 is main node and node 2 is subnode to node1 as in regard with your scenario.

Let me know if there are still any issues.

Regards,

Praveen kambala.

Former Member
0 Kudos

If still that problem exists, please check the cardinality of the subnode.

If it is 0..n please create an instance element in wddoinit Method of the view.Then it will be resolved else change the cardinality to

1..n.It works.

Regards,

Praveen kambala.

Former Member
0 Kudos

Sorry that was a typo, ok I'll try that out thanks.

I tried it and it didn't work. I set the subnode to have 1..n cardinality. Here is the code.

The node= CAUTH_DATA

The subnode= CAUTH_COMV


  DATA lo_nd_cauth TYPE REF TO if_wd_context_node.
  DATA lo_nd_cauth2 TYPE REF TO if_wd_context_node.

  DATA lo_el_cauth TYPE REF TO if_wd_context_element.
  DATA ls_cauth_comv_v TYPE wd_this->element_cauth_comv_v.

* navigate from <CONTEXT> to <CAUTH_COMV_V> via lead selection
  lo_nd_cauth = wd_context->path_get_node( path = `CAUTH_DATA_V` ).
  lo_nd_cauth2 = lo_nd_cauth->path_get_node( path = `CAUTH_COMV_V` ).""""""""
  lo_nd_cauth2 = lo_nd_cauth->get_child_node( name = wd_this->wdctx_cauth_comv_v ).""""""""
*  lo_nd_cauth2 = lo_nd_cauth->path_get_node( path = `CAUTH_COMV_V` ).
  lo_el_cauth = lo_nd_cauth2->get_element( ).

I was trying different ways to get a reference the two lines with the ' """"""" ' at the end both returned a null reference and so on the last line it dumps here.

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

you need to set the cardinality of node CAUTH_DATA_V to 1..N/1..1 or you need to make sure that the node contains atleast one element.

BR, Saravanan

Former Member
0 Kudos

Thank you for your response,

When you say 1 element, do you mean have an attribute in the node along with the subnode?

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

By 1 element I mean to say that there should be atleast one instance of the Node1. for creating the context element, you need to call the method IF_WD_CONTEXT_NODE->CREATE_ELEMENT( ).

BR, Saravanan

Former Member
0 Kudos

Hi,

Check the interface IF_WD_CONTEXT_NODE.

I remember, there are a couple of methods pertaining to sub-nodes and with the same you can give it a try to get instance of sub-nodes.

Let me know if it works.

Cheers,

Kunjal

Former Member
0 Kudos

Hi micheal,

create an internal table and append all the values from the node(which is mapped) after that attach the internal table to the other node,you can also try,read the values of the node for example:ls_material here material is the node which is mapped,after that send the values to the other node.Try once,hope it helps.Thanks.