cancel
Showing results for 
Search instead for 
Did you mean: 

How get value to view from componentcontroller without mapping?

Former Member
0 Kudos

Hi

I found many article about "Reading Component controller’s context node from view without mapping in Web Dynpro for ABAP" etc.http://www.saptechnical.com/Tutorials/WebDynproABAP/views/ContextNode.htm

But I need read only attribute from node with carninality 1..1.

How is it possible?

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Use get_attribute( ) method of context element to read the single attribute.

Try the below code:


  DATA lo_nd_node TYPE REF TO if_wd_context_node.

   DATA lo_controller TYPE REF TO if_wd_controller.

   data lo_context TYPE REF TO if_wd_context.

   DATA lo_node TYPE REF TO if_wd_context_node.

   DATA lo_el_node TYPE REF TO if_wd_context_element

   DATA lv_attr TYPE wd_this->element_node-attr.

*  Get Node from Component Controller

   lo_controller ?= wd_comp_controller->wd_get_api( ).

   lo_context = lo_controller->get_context( ).

   lo_node = lo_context->root_node.

   lo_nd_node = lo_node->get_child_node( name = 'NODE_NAME' ). " NODE_NAME if the name of content node

   lo_el_node = lo_nd_node->get_element( ).

* Get attribute

   lo_el_node->get_attribute(

     EXPORTING

       name `ATTR_NAME`  " ATTR_NAME is the name of Attribute in Context Node 

     IMPORTING

       value = lv_attr ).

hope this helps,

Regards,

Kiran

Former Member
0 Kudos

Hi Kiran Kumar Valluru

Thank you.

Answers (0)