on 10-27-2014 6:07 AM
Hi Guys,
I am enhancing Standard SAP WebDynpro, Adding drop-down list field into an ALV.
I added a new field with values. But when I select a value drop-down, getting following error.
The Entered Value Is Not on the List of Valid Values. |
Please find my code.
DATA: lt_mvmtype TYPE TABLE OF t157e,
ls_mvmtype LIKE LINE OF lt_mvmtype.
DATA: lr_config TYPE REF TO cl_salv_wd_config_table,
lr_column TYPE REF TO cl_salv_wd_column,
lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
lo_cmp_usage TYPE REF TO if_wd_component_usage,
lr_dropdown_key TYPE REF TO cl_salv_wd_uie_dropdown_by_key,
lt_columns TYPE salv_wd_t_column_ref,
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_node TYPE REF TO if_wd_context_node,
wa_value_set TYPE wdr_context_attr_value,
lt_value_set TYPE TABLE OF wdr_context_attr_value,
lr_drdn TYPE REF TO cl_salv_wd_uie_dropdown_by_idx,
lv_value TYPE REF TO cl_salv_wd_config_table.
FIELD-SYMBOLS <fs_column> LIKE LINE OF lt_columns.
* Get ALV Component
lo_cmp_usage = wd_this->wd_cpuse_u_alv_materials( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
* Get References for ALV
lr_comp_if_alv = wd_this->wd_cpifc_u_alv_materials( ). " get component
lr_config = lr_comp_if_alv->get_model( ). " get cofig model
lr_column_settings ?= lr_config. " get column settings
* ALV - Disable Write Protection
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
* Get Context Node
lr_node = wd_context->get_child_node( name = 'MATERIALS' ).
lr_node_info = lr_node->get_node_info( ).
* Read Movement Types
* Get Data:
SELECT * FROM t157e INTO TABLE lt_mvmtype
WHERE spras = sy-langu.
SORT lt_mvmtype BY grund.
DELETE ADJACENT DUPLICATES FROM lt_mvmtype COMPARING grund.
LOOP AT lt_mvmtype INTO ls_mvmtype.
wa_value_set-value = ls_mvmtype-bwart. " key to be saved
wa_value_set-text = ls_mvmtype-grtxt. " text to be dispalyed
APPEND wa_value_set TO lt_value_set.
ENDLOOP.
lt_columns = lr_column_settings->get_columns( ).
LOOP AT lt_columns ASSIGNING <fs_column>.
IF <fs_column>-id = 'ZZMVMT_REASON'.
CREATE OBJECT lr_dropdown_key
EXPORTING
selected_key_fieldname = 'ZZMVMT_REASON'.
ENDIF.
ENDLOOP.
** Set attribute info for planetype
lr_node_info->set_attribute_value_set( name = 'ZZMVMT_REASON'
value_set = lt_value_set ).
<fs_column>-r_column->set_cell_editor( lr_dropdown_key ).
Thanks
Sam
Hi Sam,
As Rama has mentioned, it may be caused by your population of the dropdown list.
i noticed that when you were doing a delete of duplicate entries, you are comparing with field "grund"
DELETE ADJACENT DUPLICATES FROM lt_mvmtype COMPARING grund.
i think this should have been the bwart since that is the key for our dropdown list .
To get a simple understanding of the dropdown list, may be you can hardcode the list of dropdown as follows:
LOOP AT lt_mvmtype INTO ls_mvmtype.
wa_value_set-value = ls_mvmtype-bwart. " key to be saved
wa_value_set-text = ls_mvmtype-grtxt. " text to be dispalyed
APPEND wa_value_set TO lt_value_set.
ENDLOOP
wa_value_set-value = '1'. " key to be saved
wa_value_set-text = 'First option'. " text to be dispalyed
APPEND wa_value_set TO lt_value_set.
wa_value_set-value = '2'. " key to be saved
wa_value_set-text = 'Second option'. " text to be dispalyed
APPEND wa_value_set TO lt_value_set.
If the hardcoded values are working fine, then we can be sure that the issue is caused by the values which are populated dynamically.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sam,
The error is because system could not be able to match selected value with the value list provided for drop down list.
i.e. drop down list is having values like this
00001 text 1
00002 text 2
but when you select a value, due to screen conversion, the key 1 or 2 is passed instead of 00001 or 00002.
Check out the values and try to format the list of drop down while populating it.
Hope this helps you.
Regards,
Rama
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 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.