Skip to content

POPUP_TO_CONFIRM

Show a standard yes/no confirmation dialog and return the user's choice.

Purpose

Displays SAP's built-in modal confirmation popup with a configurable title, question text, and up to two labeled buttons plus an optional Cancel button. Execution halts until the user responds; the answer comes back in the single-character exporting parameter ANSWER. Use this instead of building a custom dialog screen whenever a simple confirm/cancel decision is all you need.

Signature

Importing

Parameter Type Default Notes
TITLEBAR SPACE SPACE Window title text. Empty = no title bar.
DIAGNOSE_OBJECT DOKHL-OBJECT SPACE F1 long-text help object. Optional.
TEXT_QUESTION Required Question text shown in the body of the popup.
TEXT_BUTTON_1 'Ja' Label for button 1 (Yes).
ICON_BUTTON_1 ICON-NAME SPACE Optional icon for button 1.
TEXT_BUTTON_2 'Nein' Label for button 2 (No).
ICON_BUTTON_2 ICON-NAME SPACE Optional icon for button 2.
DEFAULT_BUTTON '1' Which button has focus: '1' = button 1, '2' = button 2.
DISPLAY_CANCEL_BUTTON 'X' 'X' to show the Cancel button; SPACE to hide it.
USERDEFINED_F1_HELP DOKHL-OBJECT SPACE Custom F1 help object for the dialog.
START_COLUMN SY-CUCOL 25 Screen column where the popup opens.
START_ROW SY-CUROW 6 Screen row where the popup opens.
POPUP_TYPE ICON-NAME Icon type shown in the popup (e.g. ICON_MESSAGE_QUESTION). Optional.
IV_QUICKINFO_BUTTON_1 TEXT132 SPACE Tooltip for button 1.
IV_QUICKINFO_BUTTON_2 TEXT132 SPACE Tooltip for button 2.

Exporting

Parameter Notes
ANSWER '1' = button 1 clicked, '2' = button 2 clicked, 'A' = Cancel or Escape.

Tables

Parameter Type Notes
PARAMETER SPAR Optional. Pass name/value pairs to substitute placeholders in TEXT_QUESTION.

Exceptions

Exception When raised
TEXT_NOT_FOUND The text specified in DIAGNOSE_OBJECT or USERDEFINED_F1_HELP does not exist.

Example

DATA lv_answer TYPE c LENGTH 1.

CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
    titlebar              = 'Delete record'
    text_question         = 'Do you really want to delete this entry?'
    text_button_1         = 'Delete'
    text_button_2         = 'Cancel'
    default_button        = '2'
    display_cancel_button = SPACE
  IMPORTING
    answer                = lv_answer
  EXCEPTIONS
    text_not_found        = 1
    OTHERS                = 2.

IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno.
ENDIF.

CASE lv_answer.
  WHEN '1'.
    " User clicked Delete — proceed
    PERFORM delete_record.
  WHEN '2' OR 'A'.
    " User clicked Cancel or pressed Escape
    MESSAGE 'Deletion cancelled.' TYPE 'S'.
ENDCASE.

Common pitfalls

Dialog mode only

This FM calls a GUI service and will cause a short dump (DYNP_SEND_IN_BACKGROUND) if executed in a background job or RFC call without a screen context. Guard with IF sy-batch = abap_false before calling it, and provide a non-interactive fallback for background execution.

ANSWER values are '1' / '2' / 'A' — not 'J' / 'N'

The answer is the button number ('1' or '2'), not a fixed yes/no letter. 'A' is returned when the user presses Escape or clicks X — from the German Abbrechen (cancel).

  • TEXT_QUESTION is required — the FM has no default for it.
  • TEXT_BUTTON_1 and TEXT_BUTTON_2 default to the system locale's "Yes/No" translation. Override them to use action-specific labels like "Delete" / "Keep".
  • DISPLAY_CANCEL_BUTTON defaults to 'X' (Cancel shown). Pass SPACE if you want a strict two-choice dialog.
  • DEFAULT_BUTTON sets which button gets focus (Enter key). Default is '1'. For destructive actions, set it to '2' so the safe option is the default.

See also

  • F4_FILENAME — file-picker dialog for upload/download scenarios
  • Transaction SE37 — test the FM directly in the function builder

Comments