cancel
Showing results for 
Search instead for 
Did you mean: 

WD_CONTEXT&CHILD_NODE

Former Member
0 Kudos

Hi all,

In view, we can see WD_CONTEXT which is TYPE REF TO IF_WD_CONTEXT_NODE.

In IF_WD_CONTEXT_NODE-GET_CHILD_NODE, we can see parameter CHILD_NODE is also TYPE REF TO IF_WD_CONTEXT_NODE.

I tried to use WD_CONTEXT directly when I want to get the value of the element like WD_CONTEXT->GET_CHILD_NODE(but this is wrong).

Could anyone tell me what exactly is WD_CONTEXT&CHILD_NODE?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The WD_CONTEXT attribute is a reference to the root node of the context of the controller.  Regardless of the edited controller, it is  always a reference variable of the type IF_WD_CONTEXT_NODE.

You can use WD_CONTEXT and the interface methods to edit the content of a

context node in your controller method.

Ex:- The controller context contains the MY_NODE1 node.

data: TABLE_NODE type ref to IF_WD_CONTEXT_NODE.

TABLE_NODE  = WD_CONTEXT->GET_CHILD_NODE( 'MY_NODE1').

Hope this helps you.Pls revert for further clarifications.

Thanks

KH

Former Member
0 Kudos

Can I treat ' 'MY_NODE1' as an instance of root node which is referred by WD_CONTEXT?

Can I the creation of 'MY_NODE1' is an initialization of IF_WD_CONTEXT_NODE?

Since it seems that I cannot see the source code so I get a little confused:)

Former Member
0 Kudos

Hi Ming Yu,

Below is the snapshot of how it looks just FYR.

Former Member
0 Kudos

Hi, I know the structure.

What I am wondering is this MY_NODE1 is an instance of CONTEXT.

Just like CREATE OBJECT in oo programming.

Former Member
0 Kudos

Hi,

You can get the instance of node MY_NODE1 from WD_CONTEXT as shown below.

DATA lo_nd_my_node1 TYPE REF TO if_wd_context_node.

lo_nd_my_node1 = wd_context->get_child_node( name = wd_this->wdctx_my_node1 ).

Thanks

KH

Former Member
0 Kudos

Yes, and then

lo_nd_my_node1->get_element( ).


But why I can't do this

wd_context->get_element( ).


both lo_nd_my_node1 and wd_context are referring to if_wd_context_node.

what is the diff between these two.





ramakrishnappa
Active Contributor
0 Kudos

Hi Ming,

The CONTEXT is root node and it can have as many attributes and child nodes inside.

By default, every controller has the reference to CONTEXT initialized in attributes tab and created the attribute WD_CONTEXT of type ref to IF_WD_CONTEXT_NODE.

But, to access, any of its attributes or child nodes, we need to use the WD_CONTEXT object and using methods GET_ATTRIBUTE / get_child_node( ) we get the components of root context.

Similarly, child node MY_NODE1 can have as many as child nodes under it.

Regards,

Rama

Former Member
0 Kudos

Hi, I have checked the code of 'CL_WDR_CONTEXT_ELEMENT' in which 'IF_WD_CONTEXT_ELEMENT' is defined.

It seems that when you create a node like 'NODE1' in the view.

Based on code, the system creates a node object, this object has two parameters which are node name and node object reference(meanly it's address). They are appended to an internal table.

When you use GET_CHILD_NODE, the system will search the internal table and find the object reference according to the node name.

And no matter  at  which level the nodes are, they are not allowed to have the same name.

It means that you cannot define a NODE1 under a NODE1. I think that based on the source code, the nodes do not have levels.

Answers (1)

Answers (1)

Former Member
0 Kudos

wd_context is just a reference to you ROOT node

If you have attributes directly in root - context (without any node) you can get These values wie wd_context->get_attribute