on 01-21-2010 3:09 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.