Skip to Content
avatar image
Former Member

Read attribute values of the subnode using the parent node reference.

Hi all,

There is table in the a standard web dynpro component which has country field. It is customized and a field for region is added. The standard dropdown for countries has fixed set of values for countries. However, the dropdown values for the region dropdown should be dynamic and it has to be based on the input country in the previous (country) column of the same, i need different dropdown values for same column. To achieve this, I have used dropdown by index and created a childnode 'Region' inside the main node. This region has two attibutes ie., value and text. Using the below code i am able to achieve the dynamic dropdowns.

      name =  `COUNTRY`
      value = lv_country ).

  LOOP AT it_t005u INTO wa_t005u WHERE land1 EQ lv_country.
    ls_dropdown-value = wa_t005u-bland .
    ls_dropdown-text = wa_t005u-bezei .
    APPEND ls_dropdown TO lt_dropdown.

  lo_node = lo_nd_work_location_table->get_child_node('REGION').
  lo_node->bind_table( new_items = lt_dropdown set_initial_elements = abap_true ).

But, after entering all the values in the table through the UI, I need to read values entered in the table. I am able to get all the attributes of the node, using normal 'get_static_attibutes' of the method. now, to get the region, I need to read the child node 'REGION' s attributes. ie., using the parent node reference, I need to read the child node and the attributes inside that child node for all the entries in the table. For this, I have used the following code.

  lo_parent_node = wd_context->get_child_node( name = wd_this->wdctx_work_location_table ).
  lt_elements = lo_parent_node->get_elements( ).
  LOOP AT lt_work_location_table INTO ls_work_location.
          CLEAR lo_el_content.
          READ TABLE lt_elements INTO lo_el_content INDEX sy-tabix.
          IF sy-subrc EQ 0.
            lo_child_node  = lo_el_content->get_child_node( 'REGION' ).
            lo_el_child    = lo_child_node->get_lead_selection( ).
            IF lo_el_child IS BOUND.
              CALL METHOD lo_el_child->get_attribute
                  name  = 'TEXT'
                  value = lv_string.

In the table lt_elements i am getting the number of references = no. of rows entered.

My idea is to read the child node 'region' using the index selected ( as this is inturn a table now) ie., the value selected in the screen among the regions in the dropdown of that particular country (ie., for that row.)

Here, my ' lo_el_child = lo_child_node->get_lead_selection( ).' is returning null value. even the entire region child node is null if i see in the debug mode. So, can anyone please tell me how to read the value of the attributes of the subnode using the reference of the parent node.

Thanks and Regards,

Avinash Bolisetty

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 26, 2011 at 09:17 PM

    When i look at you code, it seems okay. However i am not sure why

    lo_child_node = lo_el_content->get_child_node( 'REGION' ) is null.

    READ TABLE lt_elements INTO lo_el_content INDEX sy-tabix. may be a problem.

    lo_el_content is this if_wd_context_element type ?

    See the below thread on which Myself and Thomas Jung posted code snippet. Please see if you can modify your code accordingly.

    [Bind a complex structure|Bind a complex structure]

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Baskaran,

      Thankyou very much for the response.

      Yes, my lo_el_content is this if_wd_context_element type only and the read statement is also passing each reference correctly to the work area when i see in the debug mode.

      As per that link, I have tried to get the data from the child node into an internal table 'bind_table'. But the region table is not getting populated for any of the row.

      I think that means the data itself is not getting stored in the child node 'region'.

      But again, if it is not stored, i shouldnt have got the dropdowns. And for testing, I have even created an 'on select' method for the region dropdown and checked. All the text and values that are selected in the dropdown are getting stored in the child node if i check using the normal read attribute method as below on entry of region in each row.

            name =  `TEXT`
            value = lv_text ).

      I should be missing something. Can you please tell me if there is anything explicitly that is to be done while storing data in the child node and map this to the parent node (other than normal binding the ui element with the context attribute of child node.)

      Thanks and Regards,

      Avinash Bolisetty

      Edited by: Avinash Bolisetty on May 27, 2011 12:13 AM