Wednesday, April 3, 2019

Populte filepath on selection screen

  DATAlt_filetab   TYPE filetable,
              lk_filetab  TYPE file_table,
              lc_title      TYPE string,
              lk_rc         TYPE i.

  lc_title 'Select local file'(004).

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            lc_title
      file_filter             ',*.*,*.*.'
      initial_directory       ': '
    CHANGING
      file_table              lt_filetab
      rc                      lk_rc
    EXCEPTIONS
      file_open_dialog_failed 1
      cntl_error              2
      error_no_gui            3
      not_supported_by_gui    4
      OTHERS                  5.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    READ TABLE lt_filetab INTO lk_filetab INDEX 1.
    IF sy-subrc EQ 0.
      p_filepath lk_filetab-filename.
    ENDIF.
  ENDIF.

No comments:

Post a Comment