cancel
Showing results for 
Search instead for 
Did you mean: 

input filed with default value

Former Member
0 Kudos

Hi iam Ravi,

I am new to web dynpro bap.i want to make input field with default value with drop down list values.how to achieve that.in input fied there is no default value.pls help me

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Folks,

This site is very helpful who want to learn SAP.

Former Member
0 Kudos

hi Ravi,

what I understood is you have a inputfield and which is having a drop down and you want the default one right.

then

  • create local data variable to access context information

Data: context_node type ref to if_wd_context_node.

DATA: index type i.

context_node = wd_context->get_child_node( name = 'DROPDOWN_CITY').

  • Set displayed value of dropdown by index UI element.

index = 3. "sets dropdown value to the third entry in the drop down table

context_node->set_lead_selection_index( index = index ).

REGARDS,

Devi

Former Member
0 Kudos

Hi,

initially i have to set default value and later on if end user wants to modify value then how?

Former Member
0 Kudos

Hi,

Basing on some condition we can set the default value with lead selection index.

If your application is using many end users means we cant set default value for each user in that case you create a custom table and maintain the configurtion data basing on this z custom table we can set the lead selection and whenever user wants to change the default value index from 1 to 9 simply we can change inthe custom table data and then our application decides from this table which value should be default.

Regards,

Devi

former_member459142
Participant
0 Kudos

Hi Ravi,

For initialize default value, you have to set value in WDINIT method as told by other.

now for your other requirent do one thing

Create action in dropdown on select.

now in action you do get_attribute of that field and do set_attribute



METHOD onactionquest_change .
   DATA: lv_zzquest_typ TYPE wd_this->element_attribute_list-zzquest_typ,
               lo_nd_attribute_list     TYPE REF TO if_wd_context_node,
               lo_el_attribute_list       TYPE REF TO if_wd_context_element.

               lo_nd_attribute_list = lo_el_comp_context->get_child_node( name = wd_this->wdctx_attribute_list ).
               lo_el_attribute_list = lo_nd_attribute_list->get_element( ).

*              get single attribute
               lo_el_attribute_list ->get_attribute(  EXPORTING name =  `ZZQUEST_TYP` IMPORTING value = lv_zzquest_typ ).

*               set single attribute
                lo_el_attribute_list ->set_attribute( name =  `ZZQUEST_TYP` value = lv_zzquest_typ ).
  endmethod.

Thanks & Regards

Prashant Gupta

Former Member
0 Kudos

Create a domain in your DDIC and create your domain values there. Create a data element from this domain. In your webdynpro context , create a attribute of type the dataelement you created above.

This will work.

Former Member
0 Kudos

Hi,

When we are going to run this application user can want to see input field with default value and then if he wants he can change to any other value that is available in drop down

Former Member
0 Kudos

That is what exactly will happen if you use domain value-data element bind to input field.

Former Member
0 Kudos

How it will show default value if we use data element

gill367
Active Contributor
0 Kudos

Default value you can set by setting the attribute in the init method.

using set_attribute method of the node

thnks

sarbjeet singh

Former Member
0 Kudos

Thank for all of you.For providing valuable solutions

Former Member
0 Kudos

In my WD application thers is country filed.For this field we assign dictionary structure country names table.when ever we run this application for this country field we can set 'IN 'as default value and if you want to modify we can modify to any other country name

Former Member
0 Kudos

Hi Ravi,

In dropdown there are many values, which value you want in input field?

What is your exact requirement, please explain..

Cheers,

Kris.

Former Member
0 Kudos

In my WD application thers is country filed.For this field we assign dictionary structure country names table.when ever we run this application for this country field we can set 'IN 'as default value and if you want to modify we can modify to any other country name

Former Member
0 Kudos

Hi Ravi,

So you want to set defalut value always IN... right.

Goto WDDOINIT METHOD.

For example.. i am taking one attribute TEXT and setting with defalut value 'IN'. u can change accordingly..

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->Element_context.

DATA lv_text TYPE wd_this->Element_context-text.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

lv_text = 'IN'.

  • set single attribute

lo_el_context->set_attribute(

name = `TEXT`

value = lv_text ).

Cheers,

Kris.

gill367
Active Contributor
0 Kudos

You can create a dropdown and then fill the dropdown with all the required values.

then set the attribute to the default value.

for filling the dropdown yu can fetch the values from the databse table or create you own entries.

fill it in the valueset for dropdownbykey or fill it in node as elements for dropdownby index.

then set the default value.

thanks

sarbjeet singh

Former Member
0 Kudos

sorry...answer to the other question.

Edited by: Aditya Karanth on Mar 8, 2011 4:54 AM