cancel
Showing results for 
Search instead for 
Did you mean: 

Webdynpro abap- navigation to context node

YogSSohanee
Participant
0 Kudos

Hello all,

I am a new user for Webdynpro - abap. I was trying to set a default value to a input field. I am using WDDOINIT method for navigation to context node FLIGHTINFO. But i am not getting the exact idea behind the navigation at code level. Also not clear about get element at lead selection for context node FLIGHTINFO.

Please provide inputs in this case.

Thanks,

Yogesh

Accepted Solutions (1)

Accepted Solutions (1)

saket_abhyankar
Active Participant
0 Kudos

Hi

Use following code in the WDDOINIT method of view to set default value to input field:

Replace cn_node by your node name and ca_test by your attribute name

DATA lo_nd_cn_node TYPE REF TO if_wd_context_node.

DATA lo_el_cn_node TYPE REF TO if_wd_context_element.

DATA ls_cn_node TYPE wd_this->element_cn_node.

DATA lv_ca_test LIKE ls_cn_node-ca_test.

  • navigate from <CONTEXT> to <CN_NODE> via lead selection

lo_nd_cn_node = wd_context->get_child_node( name = wd_this->wdctx_cn_node ).

  • get element via lead selection

lo_el_cn_node = lo_nd_cn_node->get_element( ).

  • set single attribute

lo_el_cn_node->set_attribute(

EXPORTING

name = `CA_TEST` " name of attribute where input field is bound

value = lv_ca_test ). "Value that you want to set as default

What do you mean by navigation to context node and code level?

Regards,

Saket.

YogSSohanee
Participant
0 Kudos

Actually i was trying to get my concepts clear about Navigation to context node, because i was not able to understand the method implementation coding. It would be great if i get the exact flow of the program and this method execution.

Edited by: YOGESHSOHANEE on Jan 22, 2010 5:45 AM

Former Member
0 Kudos

Hi Yogesh,

Please go thru this [Link|http://help.sap.com/saphelp_nw70/helpdata/EN/d2/8acd409cc4dd50e10000000a1550b0/content.htm] to get an clear idea about the flow of data in Webdynpro application.

Regards,

Padmam.

saket_abhyankar
Active Participant
0 Kudos

Hi

There can be many nodes in the context, and many elements in each node. In order to set the default value to one of the attributes, we need to proceed as follows:

1) Get the reference of node, whose attribute needs to be defaulted. Following is the code for the same:

DATA lo_nd_cn_node TYPE REF TO if_wd_context_node.

  • navigate from <CONTEXT> to <CN_NODE> via lead selection

lo_nd_cn_node = wd_context->get_child_node( name = wd_this->wdctx_cn_node ).

wd_context has the reference of context node (root node). It gives the reference of desired node (its child node) using method get_child_node. We pass the name of desired node as parameter of this method.

2) In similar way we proceed to get the reference of desired element using following code:

DATA lo_el_cn_node TYPE REF TO if_wd_context_element.

  • get element via lead selection

lo_el_cn_node = lo_nd_cn_node->get_element( ).

3) This element may have many attributes. We set the default value to attribute of selected node using following code:

  • set single attribute

lo_el_cn_node->set_attribute(

EXPORTING

name = `CA_TEST` " name of attribute where input field is bound

value = lv_ca_test ). "Value that you want to set as default

Follow the links for more help:

http://help.sap.com/erp2005_ehp_04/helpdata/EN/46/14cf058d484250e10000000a1553f6/content.htm

http://help.sap.com/erp2005_ehp_04/helpdata/EN/46/1b994f0c475a67e10000000a1553f7/content.htm.

Regards,

Saket.

0 Kudos

Thank you Saket.

It was very helpful to me.

Regards,

Aankamma.

Answers (1)

Answers (1)

Former Member
0 Kudos

You can even set default value of input field by setting default value to context attribute binded to iput field.

Or You can use Code Wizard (control + F7 ) to do so.