Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

Not what you were looking for? View more on this topic or Ask a question