TYPE-POOLS: slis.
*--------------------------------------------------------------*
*Data Declaration
*--------------------------------------------------------------*
DATA: gt_spfli     TYPE TABLE OF spfli.
DATA: gwa_spfli    TYPE spfli.
DATA: gwa_selfield TYPE slis_selfield.
*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
PARAMETER: p_carrid TYPE spfli-carrid.

*--------------------------------------------------------------*
*Selection-Screen on Value-Request
*--------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_carrid.

  CLEAR: gwa_selfield.

*Get data
  SELECT * FROM spfli INTO TABLE gt_spfli.
*Remove duplicates
  DELETE ADJACENT DUPLICATES FROM gt_spfli COMPARING carrid.

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      i_tabname        = 'GT_SPFLI'  " Internal table name
      i_structure_name = 'SPFLI'
    IMPORTING
      es_selfield      = gwa_selfield
    TABLES
      t_outtab         = gt_spfli  " Internal table which contains entries
    EXCEPTIONS
      program_error    = 1
      OTHERS           = 2.

*User can click on any field in the popup, so just get the line index
*and get the corresponding carrid from internal table
  READ TABLE gt_spfli INTO gwa_spfli INDEX gwa_selfield-tabindex.
  IF sy-subrc = 0.
    p_carrid = gwa_selfield-value.
  ENDIF.
 
Serkan AKKAVAK
Bilgisayar Mühendisi
serkurumsal@yandex.com