SAPHub

ABAP F4 Help for File on SAP Presentation Server

Use the following steps to provide ABAP F4 help for SAP presentation server file on selection screen.

  1. Declare a input field(PARAMETER) for filename.
  2. Use function module ‘F4_FILENAME’ or ‘FILE_OPEN_DIALOG’ method of ‘CL_GUI_FRONTEND_SERVICES’ class in AT SELECTION-SCREEN ON VALUE-REQUEST FOR FIELD event to provide F4 help for SAP presentation server file.
  3. Upload data from/Download data to file.

Below program uses function module F4_FILENAME to provide ABAP F4 help for a file on presentation server.

*----------------------------------------------------------------------*
*     SELECTION-SCREEN
*----------------------------------------------------------------------*
PARAMETERS: p_file TYPE ibipparms-path OBLIGATORY.

*----------------------------------------------------------------------*
*     AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
*   EXPORTING
*     PROGRAM_NAME        =
*     DYNPRO_NUMBER      =
*     FIELD_NAME                =
   IMPORTING
     file_name           = p_file.

*----------------------------------------------------------------------*
*     START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
  WRITE:/ 'Filename : ', p_file.

When you execute the above program and press F4 help for file on selection screen, file dialog pop up will be displayed.

You can also use FILE_OPEN_DIALOG method of CL_GUI_FRONTEND_SERVICES class to provide the F4 help for presentation server file on selection screen. Below program uses FILE_OPEN_DIALOG method of CL_GUI_FRONTEND_SERVICES class to provide ABAP F4 help for a file on presentation server.

*----------------------------------------------------------------------*
*     DATA DECLARATION
*----------------------------------------------------------------------*
DATA: gv_rc TYPE i.
DATA: gt_file_table  TYPE filetable,
      gwa_file_table TYPE file_table.
*----------------------------------------------------------------------*
*     SELECTION-SCREEN
*----------------------------------------------------------------------*
PARAMETERS: p_file TYPE ibipparms-path OBLIGATORY.
*----------------------------------------------------------------------*
*     AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title = 'Select a file'
    CHANGING
      file_table   = gt_file_table
      rc           = gv_rc.
  IF sy-subrc = 0.
    READ TABLE gt_file_table INTO gwa_file_table INDEX 1.
    p_file = gwa_file_table-filename.
  ENDIF.

*----------------------------------------------------------------------*
*     START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
  WRITE:/ 'Filename : ', p_file.