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, up to two text lines, and Yes/No/Cancel buttons. 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 (the parts you'll actually use)¶
| Parameter | Direction | Type | Notes |
|---|---|---|---|
TITLEBAR |
IMPORTING | STRING |
Window title text |
TEXTLINE1 |
IMPORTING | STRING |
First line of the message body |
TEXTLINE2 |
IMPORTING | STRING |
Second line — optional |
DIAGNOSE_OBJECT |
IMPORTING | STRING |
Long-text help object — optional |
DEFAULT_BUTTON |
IMPORTING | CHAR1 |
'1' = Yes default, '2' = No default |
POPUP_TYPE |
IMPORTING | STRING |
Icon type, e.g. ICON_MESSAGE_QUESTION |
ANSWER |
EXPORTING | CHAR1 |
'J' = Yes, 'N' = No, 'A' = Cancel/Escape |
Example¶
DATA: lv_answer TYPE c LENGTH 1.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Delete record'
textline1 = 'Do you really want to delete this entry?'
textline2 = 'This action cannot be undone.'
default_button = '2' " No is the safe default
popup_type = 'ICON_MESSAGE_QUESTION'
IMPORTING
answer = lv_answer.
CASE lv_answer.
WHEN 'J'.
" User clicked Yes — proceed
PERFORM delete_record.
WHEN 'N'.
" User clicked No — do nothing
MESSAGE 'Deletion cancelled.' TYPE 'S'.
WHEN 'A'.
" User pressed Escape or closed the window
RETURN.
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.
Escape equals Cancel
If the user closes the popup window with the X button or presses Escape, ANSWER returns 'A' — the same value as the explicit Cancel button. Always handle all three possible values; defaulting to "yes on unexpected answer" is a common bug.
ANSWERis'A'for cancel, not'C'— the mnemonic comes from the German Abbrechen.- The popup is modal: no other SAP GUI interaction is possible while it is open.
TEXTLINE1andTEXTLINE2accept plain strings — avoid special formatting characters; they are displayed as-is.
See also¶
F4_FILENAME— file-picker dialog for upload/download scenarios- Transaction SE37 — test the FM directly in the function builder