ABAP F4 help using ALV

Use function module “REUSE_ALV_POPUP_TO_SELECT” to provideF4 help on the selection screen.

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.

When you press F4 on parameter p_carrid of selection screen you get the below ALV popup.

abap-alv-f4-help-1

Select any entry in the popup. In this case I will select ‘JL’ and the value will be transferred to parameter p_carrid.

abap-alv-f4-help-2


Be the first to comment

Leave a Reply

Your email address will not be published.


*