ABAP – POPUP_TO_CONFIRM with dynamic text

If you need to display dynamic text in an e.g. confirmation dialog, in which you need to place several variables (different for each popup) you can use function module POPUP_TO_CONFIRM and the parameter table.

The only thing you need to do is to prepare an internal table filled with parameters and their values. This table is then passed to the function module which will use it to replace the variable place-holdes in the text.

To create/edit text for parameter DIAGNOSE_OBJECT of the function module POPUP_TO_CONFIRM, use transaction SE61 and select DT (Dialog texts)

In the text, enter the placeholders for variables like in the following picture

Now you can use this text with your variable’s value like this:

DATA:
  lt_popup_params TYPE STANDARD TABLE OF spar,
  lv_popup_answer TYPE c.

CONSTANTS:
  co_matnr           TYPE matnr VALUE '123456789'.

APPEND INITIAL LINE TO lt_popup_params 
  ASSIGNING FIELD-SYMBOL(<ls_popup_param>).
<ls_popup_param>-param = 'MATNR'.
<ls_popup_param>-value = co_matnr.

CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
    titlebar              = 'Select Approver'(001)
    diagnose_object       = 'YVVA_YCL_IM_COND_SAVE_WFL'
    text_question         = ' '
    display_cancel_button = ' '
    start_column          = 30
    start_row             = 10
  IMPORTING
    answer                = lv_popup_answer
  TABLES
    parameter             = lt_popup_params.
IF lv_popup_answer = 1.
  WRITE 'APPROVED'.
ELSE.
  WRITE 'CANCELLED'.
ENDIF.

The resulting popup will look like this:

Leave a Reply