Skip to Content
author's profile photo Former Member
Former Member

File Directory Browse and Open Dialog Question ?

I have written this code , :

1) to let the user select the directiry he wants the files for . ( he may want to use a variant or the directory browse )

2) Let the user select the file ( file_open_dialog )

at selection-screen on value-request for path_str.

But , After the FILE OPEN DIALOG FM , when the user finally selects the file 'c:\jshdjs\mn.txt' , the filename doesnt appear in the screen field <b>path_str</b>..it just stays blank in contrast to what happens using F4_filename ( where the selected file name is filled on the screen field )

at selection-screen on value-request for <b>path_str</b>.

call method cl_gui_frontend_services=>directory_browse

exporting

window_title = 'Select Directory'

changing

selected_folder = path_str1

exceptions

cntl_error = 1.

call method cl_gui_cfw=>flush

exceptions

cntl_system_error = 1

cntl_error = 2.

  • p_path = path_str.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

EXPORTING

  • DEFAULT_FILENAME = 'C:\'

INITIAL_DIRECTORY = path_str1

CHANGING

FILE_TABLE = ITAB_FILE1_TABLE

RC = RC_FILE

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. ENDIF.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 05:30 PM

    Hi

    You have to read the table ITAB_FILE1_TABLE and extract the file selected and transfer it to selection-screen:

    W_FILE_IN TYPE FILE_TABLE

    READ TABLE ITAB_FILE1_TABLE INTO W_FILE_IN INDEX 1.

    MOVE W_FILE_IN TO path_str.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 26, 2006 at 05:36 PM

    Please see the modified code.

    
    report zrich_0001 .
    
    data: path_str1 type string.
    data: rc_file type i.
    data: itab_file1_table type table of file_table.
    data: wa_file1 like line of itab_file1_table.
    
    <b>parameters: p_file type localfile.</b>
    
    at selection-screen on value-request for <b>p_file</b>.
    
      call method cl_gui_frontend_services=>directory_browse
      exporting
      window_title = 'Select Directory'
      changing
      selected_folder = path_str1
      exceptions
      cntl_error = 1.
      call method cl_gui_cfw=>flush
      exceptions
      cntl_system_error = 1
      cntl_error = 2.
    
      call method cl_gui_frontend_services=>file_open_dialog
      exporting
    * DEFAULT_FILENAME = 'C:'
      initial_directory = path_str1
      changing
      file_table = itab_file1_table
      rc = rc_file
      exceptions
      file_open_dialog_failed = 1
      cntl_error = 2
      error_no_gui = 3
    *  not_supported_by_gui = 4
      others = 5.
    
    <b>  read table itab_file1_table into wa_file1 index 1.
      if sy-subrc  = 0.
        p_file = wa_file1-filename.
      endif.</b>
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.