SAP dropdown list box for an ABAP report selection screen

The ABAP code below is a simple program which selects entries from the SAP table EKKO and displays them as a report dropdown listbox, for the user to select from.


*.............................................................
*: Report:  ZRESTRICT_SELOPT                                 :
*:                                                           :
*: Author:  www.SAPdev.co.uk                                 :
*:                                                           :
*: Date  :  2009                                             :
*:                                                           :
*: Description: Demonstrates how to display values as an SAP :
*:              dropdown listbox                             :
*:                                                           :
*:...........................................................:
REPORT ZLISTBOX.
types: begin of t_ekko,
  ebeln type ekko-ebeln,
  end of t_ekko.
data: it_ekko TYPE STANDARD TABLE OF t_ekko,
      wa_ekko like line of it_ekko.
TYPE-POOLS: VRM.
DATA: NAME  TYPE VRM_ID,
      LIST  TYPE VRM_VALUES,
      VALUE LIKE LINE OF LIST.
PARAMETERS: P_PARM(10) AS LISTBOX VISIBLE LENGTH 10.
*********************************************************
*AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN OUTPUT.
  SELECT ebeln
   up to 10 rows
    from ekko
    into table it_ekko.
  loop at it_ekko into wa_ekko.
    VALUE-KEY =  wa_ekko-ebeln.
    VALUE-TEXT = wa_ekko-ebeln.
    APPEND VALUE TO LIST.
  endloop.
  NAME = 'P_PARM'.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID     = NAME
      VALUES = LIST.
********************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
  WRITE: / 'SELECTED VALUE KEY:', P_PARM.

Also see Trigger user command from listbox


Related Articles

Adding buttons to an ABAP report selection screen within SAP
Add buttons to Application toolbar of selection screen
Add buttons with icon to selection screen
Add buttons to dynamically change the selection screen entry fields
ABAP parameter as checkbox plus initiate 'AT selection-screen' EVENT to unselect other checkboxes
Initiate the 'AT selection-screen' EVENT from a checkbox
Dynamically alter a selection screen based on user
Initiate the 'AT selection-screen' EVENT from a LISTBOX within an ABAP report sel screen
ABAP Radiobutton to Initiate the 'AT selection-screen' EVENT on SAP report
ABAP Begin of Block to group selection-screen fields plus add title and frame
Report Selection Screen - Example code and information on various sel screen processing techniques
Selection screen push buttons
F4 search help manually called from report selection screen
Modify Selection Screen(LOOP AT SCREEN)
Restrict select-options to only allow specific restrictions
Radiobutton (inc desc) and entry field on same line of SAP selection screen
Add blank line to SAP report selection screen
Add Tab strip to Selection Screen