on 05-07-2008 1:59 AM
In the WDA class I'm taking right now (NET310), it shows you how to get the child node of the root context, find the lead selection among its elements, and then set or get attributes of this element.
But suppose you have a context hiearchy in which the root has the child A, A has the child B, and B has the child C.
Also suppose that you want to set/get some attributes of a non-initial element of C.
To "get to" an element of C, do you have to start at the root, get addressability to A, then use this to get addressability to B, and then use this to get addressability to C? (So that you can do something with an element of C.)
Or is there a way of directly obtaining addressability to an element of C, so that you don't have to "chain down" from the root?
Am I missing something here? (Probably.)
Hi,
Ideally, you can just use the Webdynpro Code wizard (Ctrl + F7) on the toolbar. This wizard allows you to select the node you want to work with and automatically generates the code for it.
For eg. I had defined something like Root -> Child1 -> child2 -> child 3. I read the context node Child3, using the wizard. It generated the following piece of code for me:
DATA lo_nd_child3 TYPE REF TO if_wd_context_node.
DATA lo_el_child3 TYPE REF TO if_wd_context_element.
DATA ls_child3 TYPE wd_this->element_child3.
* navigate from <CONTEXT> to <CHILD3> via lead selection
lo_nd_child3 = wd_context->path_get_node( path = `ROOT.CHILD1.CHILD2.CHILD3` ).
* @TODO handle non existant child
* IF lo_nd_child3 IS INITIAL.
* ENDIF.
* get element via lead selection
lo_el_child3 = lo_nd_child3->get_element( ).
* @TODO handle not set lead selection
IF lo_el_child3 IS INITIAL.
ENDIF.
* get all declared attributes
lo_el_child3->get_static_attributes(
IMPORTING
static_attributes = ls_child3 ).
Hope this helps
Regards,
Wenonah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.