ABAP PopUp: Types and Samples codes

handle PopUp in ABAP

ABAP PopUps are rich enough to do different functions.

In this articles, I will try to details the most used Abap Popup window kind with sample SAP ABAP code of course to help you implement it quickly.

Differents ABAP Popups

Abap Popup to Confirm

This is a an Abap Popup yes no. The return of the PopUp function will be
‘ ‘ for No and J for Yes.

This PopUp can also used as Abap Popup to Confirm Value.

  DATA:lv_answer.

  CALL FUNCTION 'POPUP_CONTINUE_YES_NO'
    EXPORTING
      textline1 = 'Are you sure to leave program ?'
      titel     = 'POPUP_CONTINUE_YES_NO'
    IMPORTING
      answer    = lv_answer.
  IF lv_answer = 'J'.
    LEAVE PROGRAM.
  ENDIF.
POPUP_CONTINUE_YES_NO


OR

DATA: lv_answer. 

   CALL FUNCTION 'POPUP_TO_CONFIRM_DATA_LOSS'
    EXPORTING
      defaultoption = 'J'
      titel         = 'Exit Program'
    IMPORTING
      answer        = lv_answer.
  IF lv_answer = 'J'.
    LEAVE PROGRAM.
  ENDIF..

Others PopUps functions can be used for Abap Popup to display text
POPUP_TO_DECIDE_WITH_MESSAGE
POPUP_TO_DECIDE

Abap Popup with input field Or Value

Abap Popup to inform

Display text/message in PopUp with the function POPUP_TO_INFORM.

  CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
      titel = 'Information'
      txt1  = 'Information line 1'
      txt2  = 'Information line 2'
      txt3  = 'Information line 3'
      txt4  = 'Information line 4'.
POPUP_TO_INFORM

Abap Popup with table display

Display a table in PopUp.
POPUP_WITH_TABLE_DISPLAY

" lt_tab type of any 
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
    EXPORTING
      endpos_col         = 80
      endpos_row         = 25
      startpos_col       = 1
      startpos_row       = 1
      titletext          = 'PopUp Title for Display Table'
*   IMPORTING
*     CHOISE             =
    TABLES
      valuetab           = lt_tab
   EXCEPTIONS
     break_off          = 1
     OTHERS             = 2

In order to display BAPIRET2 table messages when checking or saving a transaction, I recommend using this C14Z_MESSAGES_SHOW_AS_POPUP

" Types for messages: PopUp Table
  TYPES: BEGIN OF esp1_message_wa_type,
           msgid  LIKE sy-msgid,
           msgty  LIKE sy-msgty,
           msgno  LIKE sy-msgno,
           msgv1  LIKE sy-msgv1,
           msgv2  LIKE sy-msgv2,
           msgv3  LIKE sy-msgv3,
           msgv4  LIKE sy-msgv4,
           lineno LIKE mesg-zeile,
         END OF esp1_message_wa_type.

  DATA: lt_message_popup TYPE TABLE OF esp1_message_wa_type.
  DATA: lt_bapiret_tab   TYPE TABLE OF bapiret2. " BAPIRETTAB
  
  FIELD-SYMBOLS:  like LINE OF lt_bapiret_tab. 
  FIELD-SYMBOLS:  like LINE OF lt_message_popup.
  
  " Fill lt_bapiret_tab with Transaction return 
  
  " Prepare Table for PopUP
  LOOP AT lt_bapiret_tab ASSIGNING 
     WHERE type is NOT INITIAL. " avoid dumb for none relevant message

    APPEND INITIAL LINE TO lt_message_popup ASSIGNING .
    -msgty = -type .
    -msgid = -id .
    -msgno = -number .
    -msgv1 = -message_v1 .
    -msgv2 = -message_v2 .
    -msgv3 = -message_v3 .
    -msgv4 = -message_v4 .
    -lineno = sy-tabix.

  ENDLOOP.
  
  " Call the PopUp Table
  IF NOT lt_message_popup[] IS INITIAL.
    CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'
      TABLES
        i_message_tab = lt_message_popup[].
  ENDIF.

Display SLG1 log Like PopUp in ABAP

To Display a SLG1 log in a Popup in ABAP used the standard function OXT_MESSAGE_TO_POPUP

When digging into OXT_MESSAGE_TO_POPUP, the core is based on the other more commun function BAL_DSP_LOG_DISPLAY used in displaying log.

The input for OXT_MESSAGE_TO_POPUP is a table typed BAPIRETTAB.

Display popup screen within ABAP Web dynpro

Check this post about PoPUp in WebDynPro ABAP

ABAP PopUps Programs Sample

Check these standard ABAP Programs to find more about PopUp in SAP. These sample programs focus how to display to Log ( SLG1 ).
SBAL_DEMO_04_POPUP
SBAL_DEMO_04_POPUP_S

SAP develops a cool option for both these programs to display Tables in PopUp in Grid Mode

Actually, the standard use the display profile parameter while calling BAL_DSP_LOG_DISPLAY.

" use grid for display if wanted ls_display_profile-use_grid = p_grid. " 'X' or ' '