How to display a popup with items for selection in ABAP

SAPIn case you’d like to display a popup with list of values where user can select one or more values than follow the code snippet

 

REPORT ztest.

 TYPE-POOLS: slis.

 DATA: BEGIN OF lt_data OCCURS 0.
         INCLUDE STRUCTURE sflight.
 DATA:   chk TYPE c,                 "For multiple selection
       END OF lt_data.

 DATA:
   l_selfield TYPE slis_selfield.

 PARAMETERS: p_title TYPE sy-title.  " Popup dialog caption

 START-OF-SELECTION.

   SELECT * FROM sflight INTO TABLE lt_data.

   CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
     EXPORTING
       i_title              = p_title
       i_selection          = 'X'
       i_zebra              = 'X'
       i_checkbox_fieldname = 'CHK'
       i_tabname            = 'LT_DATA'
       i_structure_name     = 'SFLIGHT'
     IMPORTING
       es_selfield          = l_selfield
     TABLES
       t_outtab             = lt_data
     EXCEPTIONS
       program_error        = 1
       OTHERS               = 2.

   WRITE: 'Selected entries:'.

   LOOP AT lt_data WHERE w_chk = 'X'.
     WRITE: / lt_data-carrid, lt_data-price.
   ENDLOOP.

Leave a Reply