Skip to content

POPUP_GET_VALUES

Display a generic input dialog with labeled fields and return the values the user enters.

Purpose

POPUP_GET_VALUES shows a modal popup with up to 10 labeled input fields. The user fills in the fields and clicks OK or Cancel. Use it when you need one or two user inputs without building a full selection screen or dynpro.

For read-only display with a message, use POPUP_TO_DISPLAY_TEXT instead. For a confirm/cancel dialog, use POPUP_TO_CONFIRM.

Signature

Parameter Direction Type Description
POPUP_TITLE Importing STRING Title bar text
START_COLUMN Importing SY-CUCOL Popup horizontal position (default: 20)
START_ROW Importing SY-CUROW Popup vertical position (default: 5)
FIELDS Tables SVAL Field definitions — one row per input field
RETURNCODE Exporting SY-SUBRC ' ' = OK, 'A' = user cancelled

SVAL structure (one row per field)

Field Description
TABNAME Dictionary table name (for type reference)
FIELDNAME Field name within the table
FIELDTEXT Label shown next to the input (overrides field label)
VALUE Initial value (also receives the user-entered value after return)
NOEDIT 'X' = display only

Example — input dialog with two fields

DATA lt_fields TYPE STANDARD TABLE OF sval.
DATA lv_cancel TYPE char1.

APPEND VALUE #(
  tabname   = 'LFA1'
  fieldname = 'LIFNR'
  fieldtext = 'Vendor number'
) TO lt_fields.

APPEND VALUE #(
  tabname   = 'T001W'
  fieldname = 'WERKS'
  fieldtext = 'Plant'
  value     = '1000'   " default value
) TO lt_fields.

CALL FUNCTION 'POPUP_GET_VALUES'
  EXPORTING
    popup_title = 'Enter selection criteria'
    start_column = 30
    start_row    = 5
  IMPORTING
    returncode   = lv_cancel
  TABLES
    fields       = lt_fields
  EXCEPTIONS
    error_in_fields = 1
    OTHERS          = 2.

IF sy-subrc <> 0 OR lv_cancel = 'A'.
  LEAVE PROGRAM.   " or RETURN from subroutine
ENDIF.

" Read returned values from the table
DATA(lv_vendor) = VALUE lifnr( lt_fields[ fieldname = 'LIFNR' ]-value DEFAULT space ).
DATA(lv_plant)  = VALUE werks_d( lt_fields[ fieldname = 'WERKS' ]-value DEFAULT space ).

WRITE: / 'Vendor:', lv_vendor, '  Plant:', lv_plant.

Example — confirm dialog

DATA lv_answer TYPE char1.

CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
    titlebar      = 'Confirm deletion'
    text_question = 'Delete all selected records?'
    text_button_1 = 'Delete'
    text_button_2 = 'Cancel'
    default_button = '2'
  IMPORTING
    answer        = lv_answer
  EXCEPTIONS
    OTHERS        = 1.

IF lv_answer <> '1'.
  RETURN.
ENDIF.

Common pitfalls

RETURNCODE space ≠ sy-subrc = 0

The cancellation flag is in the RETURNCODE exporting parameter ('A' = cancelled), not in sy-subrc. Always check RETURNCODE — sy-subrc only reflects exceptions.

TABNAME and FIELDNAME must exist in the Data Dictionary

The FM uses the field metadata for input validation and field formatting. If the table or field name is wrong, the popup raises ERROR_IN_FIELDS.

  • Custom label: Set FIELDTEXT to override the Data Dictionary field label with your own text.
  • Non-editable fields: Set NOEDIT = 'X' to display a value that the user cannot change.
  • Position: START_COLUMN and START_ROW are screen character coordinates. The defaults (20, 5) work for most cases.

See also

Comments