cancel
Showing results for 
Search instead for 
Did you mean: 

How to write nested nodes in context

Former Member
0 Kudos

Hi,

I have two nodes in my context:

node "client" (0..n) with one attribute "name" and one node nested "car" (0..n) that has one attribute "l_plate".

root

client (0..n)

car (0..n)

How do I write data to this context?

Do I have to create an element car first, so bind it to a element client?

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Silke,

the problem is that IF_WD_CONTEXT_ELEMENT doesn't have the bind method. How can I bind a car to a client?

If I use the node client.car, how can I be sure that a car is binded to the corrected client?

Thanks a lot.

Former Member
0 Kudos

Jorge, if the context clients-node does already contain all the elements, the next step could be

to loop over these clients-elements and to get the cars-node for every client-element and to bind the

cars-table to the cars-node.


  data lr_client_node type ref to if_wd_context_node.
  data lt_client_elem type wdr_context_element_set.
  data lr_client_elem type ref to if_wd_context_element.

  data lr_car_node type ref to if_wd_context_node.
  
* get all client elements
  lt_client_elem = lr_client_node->get_elements( ).

* for every client element in the client node
  loop at lt_client_elem into lr_client_elem.

* possibly we need a client id to find the right cars
    lr_client_elem->get_attribute(
      exporting
        name   = 'CLIENT_ID'
      importing
        value  = lv_client_id
    ).


    lr_car_node = lr_client_elem->get_child_node( name = if_componentcontroller=>wdctx_car ).
    
* some more coding to 
*  get the cars
*  bind the cars to this node

  endloop.

Hope this works as I don't have a system right here to check

Former Member
0 Kudos

Thanks a lot Silke,

the main point was the method call of the element:

lr_client_elem->get_child_node( name = if_componentcontroller=>wdctx_car ).

That's what I was searching.

Thanks,

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Client and car are two different nodes even you created 'car' under Client unless you make Singleton is false to the 'CAR' node there is no relation existing between nodes.

Check this Article.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60730016-dbba-2a10-8f96-9754a865...

if you want to add data to the 'CAR' use code wizard of application toolbar and then use Read Context to read the 'CAR' node.

use SET_STATIC_ATTRIBUTES to set the values to the node.

Thanks

Suman

Former Member
0 Kudos

Thanks for helping Suman, I read the article, but it says that when the lead selection of the parent element changes, the childs automatically change the lead selection.

It means that when I change the client, the content of the node car is modified too to be consistent with the parent node.

Is it correct?

Former Member
0 Kudos

Jorge, you can easily bind an internal table to a context node. Have a look at the interfaces IF_WD_CONTEXT_NODE and IF_WD_CONTEXT_ELEMENT.

1. Bind an internal table to the node client

DATA lr_ui_node TYPE REF TO if_wd_context_node.
  lr_data_node = wd_context->get_child_node( name = if_componentcontroller=>wdctx_data ).
  lr_data_node->bind_table( new_items = lt_data ).

2. Loop over the context node client and for every context element client bind an internal table containing the cars to the node cars as well.