cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch values of child nodes

Former Member
0 Kudos

In our case we need to fetch the values of node, subnode which is in tree structure(Please refer the attachment). Using code wizard we are able to fetch only one record from the table(Parent node value).

In normal table structure, Get_Static_Attribute method will provide all record which is stored in the table. But in this tree table structure we are not sure how to fetch the values of child node.

We can also use Function module to fetch the child node values but the problem here is we want to know the row number a particular child node. For example in the below screen I went to set value for the particular cell(Highlighted), but how can I figure out the row number and set value to the attribute.


Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184578
Active Contributor
0 Kudos

Hi,

Try the below code snippet in onSelect event of drop down


DATA lv_index TYPE i.

  DATA lr_child TYPE REF TO if_wd_context_node.

  DATA lv_ddval TYPE string.

lr_child =  context_element->get_child_node( name = 'PARENT.DROP_DOWN' ). " sub node

  

lv_index =  wdevent->get_data ('INDEX' ) " get index of drop down selected value

  CALL METHOD lr_child->get_attribute

  EXPORTING

    index  = lv_index

    name   = 'DDVAL'   " Here DDVAL is the attribute of the subnode

  IMPORTING

    value  = lv_ddval.

CALL METHOD context_element->set_attribute

  EXPORTING

    value  = lv_ddval

    name   = 'PDD'.

*** Here PDD is the name of the Attribute in Parent node to which drop down value is set.

Also check this document for reference;

Hope this helps u,

Regards,

Kiran

Former Member
0 Kudos

hi Kiran,

thanks for the answer, i am very much new to WDA.

the query here is

there is a Tree Table structure

it can have drop downs and normal input fields as well.

so how can I GET and SET values at particular child nodes, the child nodes is the problem.

former_member184578
Active Contributor
0 Kudos

Hi,

Have you checked the document provided in my earlier reply?. That is almost same like your requirement( set value to drop down ). That will help you.

Please revert back incase of any further clarifications.

Regards,

Kiran

Former Member
0 Kudos

hi Kiran,

my query is not specific to drop down.

my query is specific to TREE structures.

how to get and set values at CHILD nodes

former_member184578
Active Contributor
0 Kudos

Hi,

In the example, drop down indicates child node.

Or try the below code to set value to child node in general case.


lo_el_parent = lo_nd_parent->bind_structure( new_item = ls_parent     set_initial_elements = abap_false ).

lo_nd_child= lo_el_parent->get_child_node( 'CHILD_NODE' ).

lo_nd_child->bind_structure( new_item = ls_child

                                             set_initial_elements = abap_false ).

Or you can access the child node using

  


  lo_nd_nodeb = wd_context->path_get_node( path = `NODEA.NODEB` ).

Hope this helps u,

Regards,

Kiran

ramakrishnappa
Active Contributor
0 Kudos

Hi Rahul,

You can get the child node data as below


  • Let us say we have parent node "TASK_HEAD"
  • We have a child node 'TASK_DETAIL" inside the node "TASK_HEAD"
  • Get the child node reference at specified index as below
  • Find out the index of the entry DEVELOPMENT into lv_index

        

     lo_child_node =

    lo_nd_radio->path_get_node(

        path                          = 'TASK_HEAD.TASK_DETAILS'

      start_index_for_element_index = lv_index " index of the

    ).

  • using lo_child_node->get_static_attributes_table(  ), you can get the data of the child node
  • Loop over entries and set the values as required

Note: There will be keys associated to the entries of tree, get the index of row by reading data based on these keys

Hope this helps you.

Regards,

Rama