on 06-27-2013 4:47 PM
Hi all,
I cannot figure out on how to set the value back for dropdown using key value; I supposed it'll select the text description but it turned out showing the key value instead. Those attributes of context have the same data type.
Let's see the picture below for a quick understand.
Here is the coded for loading value to dropdown
===================
method WDDOINIT .
DATA : ls_V_BIND TYPE ihttpnvp,
lt_V_BIND TYPE tihttpnvp.
DATA lo_nd TYPE REF TO IF_WD_CONTEXT_NODE_INFO.
LO_ND = WD_CONTEXT->GET_NODE_INFO( ).
ls_v_bind-name = 5.
ls_v_bind-value = 'Five'.
APPEND ls_v_bind TO lt_v_bind.
ls_v_bind-name = 10.
ls_v_bind-value = 'Ten'.
APPEND ls_v_bind TO lt_v_bind.
ls_v_bind-name = 20.
ls_v_bind-value = 'Twenty'.
APPEND ls_v_bind TO lt_v_bind.
lo_nd = wd_context->get_node_info( ).
LO_ND = LO_ND->GET_CHILD_NODE( NAME = WD_THIS->wdctx_year ).
LO_ND->SET_ATTRIBUTE_VALUE_SET(
exporting
NAME = 'ZZYEAR'
VALUE_SET = lt_v_bind
).
endmethod.
======================
Here is the code for button action
========================
method ONACTIONSET .
DATA : LO_ND TYPE REF TO IF_WD_CONTEXT_NODE,
LO_EL TYPE REF TO IF_WD_CONTEXT_ELEMENT,
LS_INPUT TYPE wd_this->element_input.
DATA LS_YEAR TYPE wd_this->element_year.
LO_ND = WD_CONTEXT->GET_CHILD_NODE( name = WD_THIS->wdctx_input ).
lo_nd->get_static_attributes(
IMPORTING
static_attributes = ls_input
).
LS_YEAR-zzyear = ls_input-zzyear_start.
LO_ND = WD_CONTEXT->GET_CHILD_NODE( WD_THIS->wdctx_year ).
lo_nd->set_static_attributes( static_attributes = ls_year ).
endmethod.
Hi everyone, thanks for your comments; some of your comments does helpful that help me to find the solution.
Note: the previous data type those attributes are string.
Actually, I keep my code above the same but I just change data type of each attributes. First, I create a domain cuz it can hold value and text description; then I create a element with that domain. I haven't fix any value yet when I first create domain but as you see my above code, I assign its value dynamically in WDDOINT so that it can hold any value I want it to be.
That's it; it worked as I expected. If I input 5, then it will select the text description 'Five' in dropdown.
Thanks!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daro,
If I understand correctly the requirement is to default the value in dropdown based on the number you will enter inthe input field. For eg if you enter 20, you want 'Twenty' as default value in dropdown.
If you are still facing the problem, try the below code in onactionset method.
DATA : LO_ND TYPE REF TO IF_WD_CONTEXT_NODE,
LO_EL TYPE REF TO IF_WD_CONTEXT_ELEMENT,
lv_yr_start TYPE wd_this->element_input-zzyear_start.
LO_ND = WD_CONTEXT->GET_CHILD_NODE( name = WD_THIS->wdctx_input ).
lo_el = lo_nd->get_element( ).
* retrieve value from input context
lo_el->get_attribute(
Exporting
name = 'ZZYEAR_START'
Importing
value = lv_yr_start ).
LO_ND = WD_CONTEXT->GET_CHILD_NODE( WD_THIS->wdctx_year ).
LO_EL = lo_nd->get_element( ).
* Set in dropdown context
lo_el->set_attribute(
name = 'ZZYEAR'
value = lv_yr_start ).
Hope this helps.
Regards,
Sonia.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daro KH,
Definitely the it returns the name not the value once you select the drop down.
You can do one thing . make the name and value same like below .
while appending .
ls_v_bind-name = 'FIVE'.
ls_v_bind-value = 'Five'.
APPEND ls_v_bind TO lt_v_bind.
ls_v_bind-name = 'TEN'.
ls_v_bind-value = 'Ten'.
APPEND ls_v_bind TO lt_v_bind.
ls_v_bind-name = 'TWENTY'.
ls_v_bind-value = 'Twenty'.
APPEND ls_v_bind TO lt_v_bind.
or you can create domain .
Assign the same domain to Data element and Create a Attribute and attribute of type Data element
Bind the Drop down by Key ui Elements Selected key to attribute as shown below
The Execute Application
This should Help you !!! If any Doubts revert Back .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daro,
We use the Drop down by Key when we want to display some text and select some value.
for instance when I am putting a customer drop down for the user the name matter as to outside world KUNNR is not know so they select the name now I being a programmer am interested in KUNNR and not the name so I set the Key as kunnr and text as name solves both purpose.
If I want to show the name and get the name... a simple combo box will do.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi KH,
You can define the possible values in the Domain and create a data element.
Create a attribute in the context with this data element and bind this attribute to Drop Down By Key.
Thanks,
Naga.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Follow the link. It may help you.,
http://webdynproabap.wordpress.com/2012/07/08/drop-down-by-key/
Best regards,
Rao
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DDBK will always gives the key value pair. If you want to set the value manually do as per the above method or if you want to display the fixed vales give the domain name and if you are having values more than 30 then its better going for DDBI as DDBK will not display that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daro,
DDK always gives key value only.
Try like this..
ls_v_bind-name = 'Five'.
ls_v_bind-value = 'Five'.
APPEND ls_v_bind TO lt_v_bind.
ls_v_bind-name = 'Ten'.
ls_v_bind-value = 'Ten'.
APPEND ls_v_bind TO lt_v_bind.
ls_v_bind-name = 'Twenty'.
ls_v_bind-value = 'Twenty'.
APPEND ls_v_bind TO lt_v_bind.
Cheers,
Kris.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.