on 10-24-2008 7:04 AM
Hi All,
i'm using DropdownbyKey to display a set of values. i hav two dropdown elements. one displays char type value set and another is numc type. i'm able to get and save the char type attribute, but when i try to get the numc type attribute i am getting the following error.
The value selectedKey = "422.94" in DropDownByKey "PRICE" does not exist in the value list and is not initial either
Thanks in Advance
Murli
Edited by: Murli on Oct 24, 2008 8:04 AM
Edited by: Murli on Oct 24, 2008 8:05 AM
Hi,
Try to declare type as currency.
check the price field in sflight structrure for your reference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.....
For Dropdownbykey you have to pass the values like this....
where in the LT_OUTPUT TABLE.....for example values are like...
SLART STEXT
10 Primary school
20 Secondary school
30 Higher sec.school
40 Bachelor degree
then...
LOOP AT LT_OUTPUT INTO LS_OUTPUT.
LS_VALUESET-VALUE = LS_SUBTY-SLART.
LS_VALUESET-TEXT = LS_SUBTY-STEXT.
APPEND LS_VALUESET TO LT_VALUESET.
ENDLOOP.
Thanks & regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
LOOP AT lt_output INTO ls_output.
ls_valueset_price-value = ls_output-carrid.
ls_valueset_price-key = ls_output-carrid.
APPEND ls_valueset_price TO lt_valueset_price.
ENDLOOP.
lo_nd_output_info->set_attribute_value_set(
EXPORTING
name = 'PRICE'
value_set = lt_valueset_price ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
plz correct your code.
LOOP AT lt_output INTO ls_output.
ls_valueset_price-value = ls_output-carrid.
ls_valueset_price-text = ls_output-carrid.
APPEND ls_valueset_price TO lt_valueset_price.
ENDLOOP.
lo_nd_output_info->set_attribute_value_set(
EXPORTING
name = 'PRICE'
value_set = lt_valueset_price ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
can u please tell how u set the values. the following the way how i did it. its in doinit method.
LOOP AT lt_output INTO ls_output.
ls_valueset_price-value = ls_output-carrid.
ls_valueset_price-text = ls_output-price.
APPEND ls_valueset_price TO lt_valueset_price.
ENDLOOP.
lo_nd_output_info->set_attribute_value_set(
EXPORTING
name = 'PRICE'
value_set = lt_valueset_price ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Murli,
Am sorry I had earlier given you the coding based on a DropDownByIndex element. The key difference between the 2 types of elements is that if you make use of an DropDownByKey element:
1) Selecting a value will not change the lead selection.
2) The data stored in the context element at lead selection will be overwritten by the key value related to the selected data.
Below is the correct coding while making use of the DropDownByKey element. I have bound the selectedKey property of my dropdown to the context attribute PRICE. (type S_PRICE) This attribute is under the context node 'D'. (This node has a cardinality of 1..1 & selection of 0..1 & the lead selection is initialized)
METHOD wddoinit .
DATA: lv TYPE REF TO if_wd_context_node,
info TYPE REF TO if_wd_context_node_info,
wa TYPE wdr_context_attr_value,
it TYPE TABLE OF wdr_context_attr_value.
DATA: lt_price TYPE if_main=>elements_d,
wa_price TYPE if_main=>element_d.
SELECT distinct price FROM sflight INTO TABLE lt_price. " Just for an example am selecting DISTINCT price values from the table
LOOP AT lt_price INTO wa_price.
wa-value = wa_price-price.
wa-text = wa_price-price.
APPEND wa TO it.
ENDLOOP.
lv = wd_context->get_child_node( name = 'D' ).
info = lv->get_node_info( ).
info->set_attribute_value_set( name = 'PRICE'
value_set = it ).
ENDMETHOD.
I have associated an action onSelect for the onSelect event of the DropDownByKey & put the below coding into it.
METHOD onactiononselect .
DATA : lv_node TYPE REF TO if_wd_context_node,
lead_selection_index TYPE i VALUE 0,
lv_price TYPE sflight-price.
lv_node = wd_context->get_child_node( name = 'D' ).
CALL METHOD lv_node->get_attribute
EXPORTING
name = 'PRICE'
IMPORTING
value = lv_price.
ENDMETHOD.
After execution lv_price is containing the correct value of price selected by the user. Hope it helps resolve your problem.
Regards,
Uday
Hi Uday,
Sorry for the late reply,
When i try to use the type "IF_MAIN=>ELEMENTS_INPUT" i get an error. The type "IF_MAIN=>ELEMENTS_INPUT" is unknown.
The node name i'm using is INPUT, i hav specified the cardinality, selection and lead selection as u askd me.
I tried with the type "WD_THIS->ELEMENTS_INPUT", I'm not getting any syntax error, but i'm getting the runtime error
The value selectedKey = "422.94" in DropDownByKey "PRICE" does not exist in the value list and is not initial either
any suggestions?
Hi Murli,
You get this error message regarding saying, "The type "IF_MAIN=>ELEMENTS_INPUT" is unknown" as you must be trying to code it in a view other than MAIN view. In the lines of code which I had put down earlier as:
DATA: lt_price TYPE if_main=>elements_d,
wa_price TYPE if_main=>element_d.
So I was trying to define a structure & internal table similar to the context I had in my MAIN view. Try doing the declaration as shown below instead:
data lt_price type wd_this->elements_d.
This approach was suggested by [Thomas Jung just yesterday|; pointing out a pitfall in my approach. Below are his explanation over the same, "It is suggested that you avoid the usage of the IF_<name> interface declarations directly. If you were to rename your object, the interface name would change as well. It is better to reference the types via WD_THIS object (which will inherit from yoru IF_<NAME> interface) to avoid any code problems after renaming."
Regards,
Uday
I'm not sure that the block of code you are pointing out is related to the error message. It sounds like you are updating your selectedKey value, but it is not in the valueSet for the DDLB. Perhaps this is related to an input/output field conversion - since this is a currency field. When you set the values into the valueSet, are you doing a write statement into a string so that they get formatted for external display?
In general you should be careful using fields that are non basic character types as the key of your DDLBbyKey. If you have complex values like currency that you want to serve as the key then you should consider using the DDLBbyIndex instead or create some internal key cross reference to avoid using the currency itself as the key.
Hi,
Yes, i think i'm doing a write statement to format it for external display. I didn't know any better.
My requirement is like this, i have to display all the values of PRICE field from the table SFLIGHT in the dropdown list of the DDLB and i have to get back the selected value for further processing. How can i do that.?
Hi,
Thanks for ur reply...
I'm using the method "set_attribute_value_set" to set the value set for the dropdownbykey and all the values are getting displayed. But when i try to get the selected values by using "get_attribute method", i'm able to get the attributes for any fields related to character type. But when i do the same for any Numeric type i'm getting the error.
for example, i'm able to get the selected values from currency and planetype fields, but not for price, seatsmax, seatsocc etc..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Murli,
I did try replicating the scenario for a dropdown which was displaying the PRICE values from SFLIGHT table. The get_attribute method is working perfectly fine and is able to retrieve the selected attribute. Try mention the type of the context attribute as S_PRICE. (This is the data element for the PRICE field.)
data : lead_selection_index type i value 0,
lv_price type sflight-price.
lv_node = wd_context->get_child_node( name = 'DROPDOWN' ).
lead_selection_index = lv_node->get_lead_selection_index( ). " Get the index number of the value selected from dropdown
CALL METHOD lv_node->get_attribute "Get the corresponding value by using this index and passing the name of context attribute
EXPORTING
index = lead_selection_index
name = 'PRICE_VALUE'
IMPORTING
value = lv_price.
At the end lv_price is having the correct value of the price selected by the user from the dropdown.
Regards,
Uday
Hi Murli,
i trying to using numc its working.
where you declare type numc .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suman,
Whr should i declare the type as currency, in Dictionary table??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
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.