Sample code for listbox in Report Selection Screen

Sample code to place listbox in selection screen.

listbox sap abap report selection screen

REPORT zpwtest.

*&---------------------------------------------------------------------*
*&      Types and Data
*&---------------------------------------------------------------------*
TYPE-POOLS : vrm .

DATA : gt_values    TYPE TABLE OF vrm_value   .

PARAMETERS : p_numl TYPE i AS LISTBOX VISIBLE LENGTH 7 OBLIGATORY .

*&---------------------------------------------------------------------*
*&      Initialization
*&---------------------------------------------------------------------*
INITIALIZATION .
  PERFORM init .

*&---------------------------------------------------------------------*
*&      Start of Selection
*&---------------------------------------------------------------------*

START-OF-SELECTION .

  WRITE : p_numl .

*&---------------------------------------------------------------------*
*&      Form  init
*&---------------------------------------------------------------------*
FORM init.

  DATA ls_value TYPE vrm_value .

  CLEAR ls_value .
  ls_value-key  = '3' .
  ls_value-text = '3' .
  APPEND ls_value TO gt_values .

  CLEAR ls_value .
  ls_value-key  = '6' .
  ls_value-text = '6' .
  APPEND ls_value TO gt_values .

  CLEAR ls_value .
  ls_value-key  = '9' .
  ls_value-text = '9' .
  APPEND ls_value TO gt_values .

  CLEAR ls_value .
  ls_value-key  = '12' .
  ls_value-text = '12' .
  APPEND ls_value TO gt_values .

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = 'P_NUML'
      values = gt_values.

ENDFORM.                    "init

Leave a Reply