Skip to Content
author's profile photo Former Member
Former Member

DropdownByKey inside ALV Table - Problem with Value set

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 27, 2007 at 01:41 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 27, 2007 at 04:25 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 28, 2007 at 08:45 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 10:40 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.