Skip to Content
Former Member
Jun 13, 2007 at 06:02 PM

DropdownByKey inside ALV Table - Problem with Value set



I have Component A which has a custom controller that uses the interface controller of the ALV Component.

Custom controller has node ITAB.. that has certain attributes...

I want DropdownByKey inside the ALV Table column. I am populating the corresponding attribute of ITAB node with the value set that I want the drop down to have.

However when I execute the application..I get error

" Key XXX not present in Value Set and is not initial"

XXX is present in the Value Set table of the attribute.

<b>Following is my code in the methods of CUSTOM CONTROLLER</b>

<u>Generate Value Set</u>

nodeinfo_context = wd_context->get_node_info( ).

nodeinfo_ITAB= nodeinfo_context->get_child_node( wd_this->wdctx_ITAB ).

<u> Populate the Value Set</u>

data ls_valueset type wdy_key_value.

data it_valueset type wdy_key_value_table.

ls_valueset-key = 'FRA'.

ls_valueset-value = 'FRANCE'.

Append ls_valueset to it_valueset.

ls_valueset-key = 'SFO'.

ls_valueset-value = 'SAN FRANCISCO'.

Append ls_valueset to it_valueset.

<u>Set the Value Set for the Attribute</u>

call method nodeinfo_ITAB->SET_ATTRIBUTE_VALUE_SET


NAME = <b>'ATTR1'</b>

VALUE_SET = it_valueset.

<u>Changing ALV Column</u>

  • Get the ALV Configuration Model

ifc_alv2 = wd_this->wd_cpifc_alv2( ).

itab_alv2_config = ifc_alv2->get_model( ).

itab_alv2_config->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( abap_false ).

<u>Get the Column reference for ATTR1</u>

ref_alv2_colset = itab_alv2_config->if_salv_wd_column_settings~get_column( <b>'ATTR1'</b> ).

<u>Create the DropDownByKey Object</u>

CREATE OBJECT ref_dropdownkey

exporting SELECTED_KEY_FIELDNAME = ref_alv2_colset->id.

ref_dropdownkey->SET_SELECTED_KEY_FIELDNAME( <b>ref_alv2_colset->id</b> ).

ref_alv2_colset->SET_CELL_EDITOR( <b>ref_dropdownkey</b> ).

<u>Check the value set</u>

ref_attr_info = nodeinfo_flight_details2->get_attribute( ref_alv2_colset->id ).

I do get back the value set if I see ref_attr_info->value_set.

SO the Value Set is getting set for attribute ATTR1, but still I get Error

<b>"The value selectedKey = "SFO" in DropDownByKey "_8C" does not exist in the value list and is not initial either "</b><u></u>

SAP User