POPUP_TO_CONFIRM — Generic confirmation popup function module
POPUP_TO_CONFIRM displays a modal two-button confirmation dialog (plus an optional cancel option) and returns a single character in ANSWER: '1' for the first button, '2' for the second, or 'A' if the user cancels or presses Escape. It is a classic dynpro utility, commonly used in reports and dialog programs before executing an irreversible action such as a delete or a posting.
This page covers POPUP_TO_CONFIRM, the standard SAP function module used to ask the user a yes/no style question before proceeding with an action. It focuses on how the ANSWER value is actually interpreted, the one exception it raises, and the branching mistakes that cause dangerous actions to run when the user meant to cancel.
Published 16 Sept 2026· 1,067 words
What it does
POPUP_TO_CONFIRM opens a modal dialog box with a question text and up to two response buttons, optionally accompanied by a separate cancel option triggered by Escape or the window close button. It is used throughout SAP standard code and custom developments to interrupt a program flow and ask for explicit confirmation before something destructive or irreversible happens, such as deleting a document, reversing a posting, or overwriting existing data. It is a synchronous, screen-blocking call: the calling program waits until the user responds. It is treated as a general-purpose utility function module available for use in customer programs, not a private SAP-internal helper, though it only works in a dialog (SAPGUI) context, not in background processing.
Parameters
Only the parameters that are consistently present across releases are listed here.
- TITLEBAR (importing) - text shown in the title bar of the popup window
- TEXT_QUESTION (importing) - the question or warning text presented to the user
- TEXT_BUTTON_1 / TEXT_BUTTON_2 (importing) - labels for the two response buttons, defaults to Yes/No style text if left blank
- DEFAULT_BUTTON (importing) - which of the two buttons is initially focused
- DISPLAY_CANCEL_BUTTON (importing) - flag controlling whether a third, cancel-style escape route is offered to the user
- START_COLUMN / START_ROW (importing) - screen position where the popup is placed
- ANSWER (exporting) - single character result of the dialog: '1', '2', or 'A' for cancel/escape
Exceptions
There is effectively one exception to worry about, and one non-exception behaviour that causes most of the damage. TEXT_NOT_FOUND is raised when the function module cannot resolve the text elements it needs to build the popup; it is rare in practice and usually points to a text pool or transport inconsistency rather than a data problem. If it is swallowed with no handling, the popup is never shown, ANSWER is never populated by this call, and the program continues holding whatever value ANSWER had before the call - which in many programs is the initial blank value, and code that checks ANSWER against a specific button value rather than explicitly against all three outcomes will silently take the wrong branch. The bigger trap is that cancelling the dialog is not an exception at all: pressing Escape or closing the window returns ANSWER = 'A' with sy-subrc 0, so code that only tests for '1' versus not-'1' treats a user cancellation exactly like pressing the second button.
- TEXT_NOT_FOUND - text elements for the popup could not be resolved; ANSWER is left unset, downstream logic that assumes ANSWER is always populated takes an unintended branch
- Implicit 'A' outcome - not a raised exception, but escape/cancel returns ANSWER = 'A' with subrc 0; code that only distinguishes '1' from 'not 1' misclassifies a cancel as a rejection or, worse, as a confirmation
How to call it safely
Populate TITLEBAR and TEXT_QUESTION with meaningful, translated text, set the button labels explicitly rather than relying on defaults if the action is not a plain yes/no decision, and decide up front whether a genuine cancel option is needed via DISPLAY_CANCEL_BUTTON. After the call, check sy-subrc for TEXT_NOT_FOUND first, then branch on ANSWER using an explicit CASE covering '1', '2', and 'A' rather than a single IF/ELSE. Treat any value other than the explicit confirm button as a non-confirm, including blank, so a failed call defaults to safe behaviour rather than proceeding with the dangerous action. Never call this inside background or batch processing; there is no user present to answer it.
ECC vs S/4HANA
POPUP_TO_CONFIRM behaves the same way in S/4HANA as in ECC; it is unaffected by the technical changes of the conversion because it is a pure SAPGUI dynpro utility. It has no released successor function module. In a Fiori or SAPUI5 context it has no equivalent, since screen-blocking modal popups from a synchronous ABAP call do not fit the asynchronous OData/RAP model; UI5 applications implement confirmation dialogs client-side in JavaScript instead. For clean-core custom code intended to run under S/4HANA extensibility guidelines, calling this function module at all is a smell, since it ties logic to classic dynpro presentation rather than to a service layer.
Common pitfalls
Most incidents involving this function module are logic bugs in the calling program rather than faults in the module itself.
- Branching with IF answer NE '1' assumed to mean cancel, when in fact '2' and 'A' both fall into that branch and get treated identically even though the user made two different choices
- Branching with IF answer EQ '2' meaning proceed, so pressing Escape ('A') is silently treated as a confirmation because the ELSE branch runs the action
- Calling the function module during a background job or update task, where there is no screen to display it; the call either fails or hangs depending on context
- Ignoring TEXT_NOT_FOUND and reading a stale ANSWER value left over from a previous call earlier in the same program, causing the program to act on an old decision
- Using this popup in a tight loop over many records, forcing the user to click through dozens of confirmations instead of asking once up front
Whose problem this is
This sits entirely with the ABAP developer who wrote the calling program. Functional consultants only ever see the symptom, typically a user reporting that clicking Cancel deleted the record anyway, or that a background job appears to hang with no error. The fix is always in the calling code's branching logic around ANSWER, not in the function module or in any configuration.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-function-modules/popup-to-confirmERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.