cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Select-Options

far_sid2103
Explorer
0 Kudos

Hi

I have a select options which displays some values from where which user can select multiple values.

Now the problem here is when i press enter after selecting some values the value at first index gets replaced by the value at last index. Can you give me a reason why that is happening and what can i do to resolve it.

This is the F4 Help that is displayed:

far_sid2103_0-1714031465891.png

and this is how how the values are in select options: (First index replaced by last)

far_sid2103_1-1714031522432.png

Below is the code for implementing f4 help: 

Implemented in Event - at selection screen on value request

1. Used FM - 'F4_FIELD_ON_VALUE_REQUEST'  to capture selected values in LT_RETURN.

2. Appending values to select-options

LOOP AT lt_return INTO DATA(ls_return).
      s_tabnam-low = ls_return-fieldval.
      s_tabnam-sign = 'I'.
      s_tabnam-option = 'EQ'.
      APPEND s_tabnam.
      CLEAR: ls_return, s_tabnam.
    ENDLOOP.

Regards,

Farhan

 

Accepted Solutions (0)

Answers (2)

Answers (2)

raymond_giuseppi
Active Contributor

You sorted the list by key (the red arrow next to table name)

If you really want this order, then sort RETURN_TAB too, but that shoudn't change anything in the select criteria result in the following SELECT. (what were the values of field RECORDPOS in the RETURN_TAB?)

far_sid2103
Explorer
0 Kudos

Hi Raymond,

The values are getting captured in below order only and appended in select-options in the same order.

far_sid2103_0-1714036064324.png

But i am getting the values (while displaying) in below order, also the 1st value is getting replaced by the last value, which should not happen.

far_sid2103_1-1714036172570.png

Regards,

Farhan

 

raymond_giuseppi
Active Contributor
0 Kudos
What you see is not what you get (try to sort the proposed list by text...)
far_sid2103
Explorer
0 Kudos
Hi Raymond,
far_sid2103
Explorer
0 Kudos

Hi Raymond,

I guess sorting is not causing the problem here still tried what you suggested but it didn't work.

far_sid2103_0-1714465531260.png

This is how i am getting values in select-options, which i think is wrong because i have selected 3 unique values but only 2 unique values remain, its replacing one value with other which should not happen.

raymond_giuseppi
Active Contributor
0 Kudos

Post your code for calling F4_FIELD_ON_VALUE_REQUEST

far_sid2103
Explorer
0 Kudos

Here's the code for F4 Help 

DATA: lt_return TYPE TABLE OF ddshretval,
        ls_range  LIKE s_tabnam,
        lt_dynp   TYPE TABLE OF dynpread.

  CALL FUNCTION 'F4_FIELD_ON_VALUE_REQUEST'
    EXPORTING
      tabname           = 'Table Name'
      fieldname         = 'TABNAME'
      searchhelp        = 'Search Help Name'
      dynprofield       = 'S_TABNAM'
      multiple_choice   = 'X'
    TABLES
      return_tab        = lt_return
    EXCEPTIONS
      field_not_found   = 1
      no_help_for_field = 2
      inconsistent_help = 3
      no_values_found   = 4
      OTHERS            = 5.

  IF sy-subrc = 0 AND lt_return IS NOT INITIAL. 
    LOOP AT lt_return INTO DATA(ls_return).
      s_tabnam-low = ls_return-fieldval.
      s_tabnam-sign = 'I'.
      s_tabnam-option = 'EQ'.
      APPEND s_tabnam.
      CLEAR: ls_return, s_tabnam.
    ENDLOOP.
  ENDIF.

 

raymond_giuseppi
Active Contributor
0 Kudos

I suppose this code is part of a AT SELECTION-SCREEN ON VALUE-REQUEST on the SELECT-OPTIONS

  • Could you try to wrap the call of F4_FIELD_ON_VALUE_REQUEST between a call of FM RS_SELECTIONSCREEN_READ (read before) and of RS_SELECTIONSCREEN_UPDATE (update after) - replacing the code that add records to the select-options without updating the dynpro