Login Form

Best viewed in IE 7.0

ADVERTISEMENTS
ADVERTISEMENT

Calling a method to browse for a filename

Use the following code snippet if you need to populate a parameter P_IFILE with a filename.

F4_FILENAME has a 128 char limit but this one allows up to 1024 characters.

 

************* SELECTION SCREEN ON VALUE REQUEST ************************
at selection-screen on value-request for p_ifile.
  perform prompt_file.


*&---------------------------------------------------------------------*
*&      Form  PROMPT_FILE
*&---------------------------------------------------------------------*
*       Browse for the file name to upload
*----------------------------------------------------------------------*
form prompt_file .

  data: lt_hfile_table type table of file_table,
        wa_hfile_table type file_table,
        lv_rc          type i.

  call method cl_gui_frontend_services=>file_open_dialog
    exporting
      default_filename        = '*.*'
    changing
      file_table              = lt_hfile_table
      rc                      = lv_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_hfile_table into wa_hfile_table index 1.

    if sy-subrc = 0.
      p_ifile = wa_hfile_table-filename.
    else.
      message s001.  "A filename is required!
    endif.

  endif.

endform.                    " PROMPT_FILE

ADVERTISEMENT
Free software downloads