Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

selecting file in parameter screen

Former Member
0 Likes
652

Hi All,

I have designed a parameter screen where the user needs to enter in a file name. I wanted to use the windows file dialog that allows you to browse your directories and double click a file and it writes the file name in the parameter field with its full path, if you visually know what i mean. At the moment the user has to copy and paste the path and file name or write it.

thanks in advance

mani

4 REPLIES 4
Read only

Former Member
0 Likes
629

Hi,

Check the code below:

FORM get_filename .

CONSTANTS: lc_file TYPE DYNPREAD-FIELDNAME VALUE 'pa_file'.

  • Calling the function to get file name

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = lc_file

IMPORTING

file_name = pa_file.

ENDFORM. " get_filename

Regards

Kannaiah

Read only

Pawan_Kesari
Active Contributor
0 Likes
629

use this method on AT SELECTION_SCREEN ON VALUE_REQUEST event


CALL METHOD cl_gui_frontend_services=>file_open_dialog
*  EXPORTING
*    WINDOW_TITLE            =
*    DEFAULT_EXTENSION       =
*    DEFAULT_FILENAME        =
*    FILE_FILTER             =
*    INITIAL_DIRECTORY       =
*    MULTISELECTION          =
*    WITH_ENCODING           =
  CHANGING
    file_table              =
    rc                      =
*    USER_ACTION             =
*    FILE_ENCODING           =
*  EXCEPTIONS
*    FILE_OPEN_DIALOG_FAILED = 1
*    CNTL_ERROR              = 2
*    ERROR_NO_GUI            = 3
*    NOT_SUPPORTED_BY_GUI    = 4
*    others                  = 5
        .

Read only

Former Member
0 Likes
629

u have 2 options... use either one of them...

F4_FILENAME function module

or else

CALL METHOD cl_gui_frontend_services=>file_open_dialog

Read only

Former Member
0 Likes
629

Try the following at the AT-SELECTION-SCREEN segment whereas p_file is your file parameter:

DATA: v_filetab LIKE STANDARD TABLE OF file_table INITIAL SIZE 0,
      v_rc TYPE i.                     " Return code

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

*---- File open dialog to choose file.
  REFRESH v_filetab.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'Choose File Path'    " you can add a title for the dialog
      default_extension       = '*.*'
      initial_directory       = 'C:'                         " You can provide path where it should start
    CHANGING
      file_table              = v_filetab                 
      rc                      = v_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 ixxx WITH text-001.
  ELSE.
    READ TABLE v_filetab INTO p_file INDEX 1.
  ENDIF.

<i>Please reward points for helpful answer.</i>