cancel
Showing results for 
Search instead for 
Did you mean: 

DropdownByKey inside ALV Table - Problem with Value set

Former Member
0 Kudos
52

Hi,

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

EXPORTING

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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi all!

l have an issue program MV50AFZ1 and check two FORM

1. FORM USEREXIT_DELETE_DOCUMENT

2. FORM USEREXIT_SAVE_DOCUMENT

But this two FORM nothing code

who is here my help?

thanks

Former Member
0 Kudos

You have forgotten to set a cell variant. I had the same with setting a ProgressIndicator cell-editor to a table column as default editor. This causes the column to be hidden on the table while it did show up in the settings dialog. I removed the set_editor( lr_progressindicator) and created a cell variant instead with this lr_progressindicator. You then need to add this cell variant to your column. By default it will select the standard viewtext-cell-editor (which can only be textview and inputfield, like when you create a table yourself in a view), but if you use a cell variant, it will display the required cell editor if you set it (last line of the code).

<b>In your case, replace lr_progressindicator by your ref_dropdownkey.</b>

DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,

lr_column TYPE REF TO cl_salv_wd_column,

lr_column_header TYPE REF TO cl_salv_wd_column_header,

lr_cellvar TYPE REF TO cl_salv_wd_cv_standard,

l_cellvar TYPE string,

lr_progress_indicator TYPE REF TO cl_salv_wd_uie_progr_indicator.

lr_column_settings ?= wd_this->mr_table.

lr_column = lr_column_settings->get_column( 'STATUSBAR' ).

lr_column_header = lr_column->get_header( ).

lr_column_header->set_text( 'Completed' ).

CREATE OBJECT lr_cellvar.

l_cellvar = 'CV_SB'.

lr_cellvar->set_key( l_cellvar ).

CREATE OBJECT lr_progress_indicator.

lr_progress_indicator->set_percent_value_fieldname( 'STATUSBAR' ).

lr_progress_indicator->set_tooltip( 'completed' ).

lr_cellvar->set_editor( lr_progress_indicator ).

lr_column->add_cell_variant( lr_cellvar ).

lr_column->set_selected_cell_variant( l_cellvar ).

I hope this will solve your issues.

Former Member
0 Kudos

Cell variant does not matter in this case. This will work only by setting cell editor to drop down by key.

Former Member
0 Kudos

You will need a cell variant to make that happen though (as you can see in my piece of code). If you have another solution I'm all ears.

Former Member
0 Kudos

In setting the drop down, there is nothing wrong in your code. Though in the end to read the attribute, you can get the lead selection and then use it.

lr_element = lr_node->get_element( ).

lr_element->get_attribute( ).

Regards,

Nithya

Former Member
0 Kudos

Hi Guys,

Still having this issue. Seems DropdownByIndex DOES NOT work in a cell of a ALV Table.

It seems to set the Value Set correctly still the error is given that the Key is not in the value set.

ALso, another problem with ALV I noticed is that <b>after you personalize and save a View</b> , making it default (initial), next time your view loads, <b>the Table has NO COlumns at all</b>....

<b>Seems lots of BUGS with ALV Functionality</b>..

Please share ur thoughts on these....

Thanks

Former Member
0 Kudos

Regarding your previous post, a dropdown by key works perfectly fine inside an ALV table. I have tried it having the code in the custom controller itself and it works fine for me. I have used the value_set of type wdr_context_attr_value. That is the expected type in set_attribute_value_set method.

Have not tried a drop down by index though.

Regards,

Nithya

Former Member
0 Kudos

DId u find anything wrong in my code above ? wdr_context_attr_value gives same error to me.