0

So I've added a field with the Dropdown type as Listbox via Screen Painter (SE51).

I've binded the data to the dropdown using the PBO and the VRM_SET_VALUES function.

enter image description here

I have 2 problems with this;

  1. How do you set a selected value to the binded data?
  2. How do you get the value selected by the user.

Data is bound to the dropdown using the following code;

LOOP AT it_zzdelay_text INTO wa_zzdelay_text.
  wa_listbox-key = wa_zzdelay_text-zz_delay_reason.
  wa_listbox-text = wa_zzdelay_text-zz_delay_reason_text.
  APPEND wa_listbox TO it_listbox.
ENDLOOP.

 CALL FUNCTION 'VRM_SET_VALUES'
  EXPORTING
    id     = 'ZZ_DELAY_REASON'
    values = it_listbox.

The zz_delay_reason is the unique key and the zz_delay_reason_text is the accompanying text.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Isuru
  • 3,044
  • 6
  • 30
  • 39
  • Just use the variable used to define the screen field...? We won't be able to give any more advice without some code... – vwegert Jun 09 '17 at 18:56
  • @vwegert ay thoughts? I had to resort to creating a search help to workaround this. Want to make it right by properly implementing a dropdown controller – Isuru Jun 15 '17 at 07:53
  • Main thought right now: "Provide a COMPLETE example and not just some random code snippets." I have neither the time nor the energy to engage in elaborate guesswork. – vwegert Jun 15 '17 at 09:30

2 Answers2

0

Update:

According to your code, the field on the screen should be: ZZ_DELAY_REASON And you also need a global variant with the name.

Then you can Set/Get key value in PBO/PAI: Set value: ZZ_DELAY_REASON = 'KEY'.

Get Selected Value(key): lv_key = ZZ_DELAY_REASON

======================================================

When select list is set by VRM_SET_VALUES, you may notice it is a "Key-Value" pair. The field "KEY" is filled into the screen field value when the user selects drop box.

I could provide detailed information if you attach your code in this question.

0

Firstly, several prerequisites are to be met to make a functional drop-down:

  1. You item table should have type vrm_values
  2. Values that are showed in the list should be in field text of the item line. Key should be in field key.
  3. PARAMETER should have type LISTBOX.

After all that is done, answers for your questions would be:

  1. Relation of KEY-VALUE is done via vrm_values type. Each line of this type is an drop-down item, where text is a visible text, and key is key.
  2. Parameter automatically gets the key value after user selects the item in the listbox.

Here is the sample code:

REPORT drop-down.

TYPE-POOLS: vrm.

PARAMETERS p_werks LIKE t001w-werks VISIBLE LENGTH 20 AS LISTBOX OBLIGATORY.

DATA: t_werks TYPE vrm_values,
w_line LIKE LINE OF t_werks.

INITIALIZATION.

SELECT werks name1
  FROM t001w INTO (w_line-key, w_line-text).
APPEND w_line TO t_werks.
ENDSELECT.

AT SELECTION-SCREEN OUTPUT.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_WERKS'
values = t_werks.

END-OF-SELECTION.

WRITE: / 'Selected factory:', p_werks.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90