How to set the default value and read the selected value of a Dropdown Listbox
08:49 09 Jun 2017

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.

abap dynpro