Application Development 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: 

local drives

Former Member
0 Kudos

Hello,

is there a function or method which returns the local drives?

thks

bogdan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

FORM f9008_f4_hlp_for_pc_file.
  DATA: li_filetable TYPE STANDARD TABLE OF file_table,
        lv_return TYPE i,
        lw_filetable TYPE file_table.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
     EXPORTING
       window_title            = 'Select file for download'
       default_extension       = '.txt'
       <b>initial_directory       =  'C:'</b>     CHANGING
       file_table              = li_filetable
       rc                      = lv_return
     EXCEPTIONS
       file_open_dialog_failed = 1
       cntl_error              = 2
       error_no_gui            = 3
       OTHERS                  = 4
           .
  IF sy-subrc <> 0.
    MESSAGE e006 WITH text-077.
  ELSE.
    READ TABLE li_filetable INTO lw_filetable INDEX 1.
    v_fnam = lw_filetable-filename.
  ENDIF.

Try this out it will open with a pop-up.

If u want more search in this method

<b>cl_gui_frontend_services=>GET_SYSTEM_DIRECTORY

cl_gui_frontend_services=>DIRECTORY_LIST_FILES- this will give Lists Files in a Given Directory</b>

Change the initial directory accordingly.

Message was edited by: Judith Jessie Selvi

6 REPLIES 6

Former Member
0 Kudos

Hi Bogdan,

You can try function modules 'RZL_READ_DIR_LOCAL' and 'PC_CHECK_DRIVE'

Regards,

Ville

Message was edited by: Ville Leivo

0 Kudos

Hi Ville,

I need the local dirves list (A: C: ...) for windows platform, not the dir contains.

greetings

Bogdan

0 Kudos

Hi Bogdan,

I don't know a simple solution to print out the local drives but would it be possible for you to put all the drive letters from A to Z to an internal table. Then use one of the above function modules or that methods to test if the directory exists by looping throught your internal table where you have your drives listed from A to Z.

This is just an idea but wouldn't it work so that when these functions or that method won't return error you print out the drive letter?

I know.. It's not a pretty solution but might work..

Regards,

Ville

Former Member
0 Kudos

Hi,

FORM f9008_f4_hlp_for_pc_file.
  DATA: li_filetable TYPE STANDARD TABLE OF file_table,
        lv_return TYPE i,
        lw_filetable TYPE file_table.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
     EXPORTING
       window_title            = 'Select file for download'
       default_extension       = '.txt'
       <b>initial_directory       =  'C:'</b>     CHANGING
       file_table              = li_filetable
       rc                      = lv_return
     EXCEPTIONS
       file_open_dialog_failed = 1
       cntl_error              = 2
       error_no_gui            = 3
       OTHERS                  = 4
           .
  IF sy-subrc <> 0.
    MESSAGE e006 WITH text-077.
  ELSE.
    READ TABLE li_filetable INTO lw_filetable INDEX 1.
    v_fnam = lw_filetable-filename.
  ENDIF.

Try this out it will open with a pop-up.

If u want more search in this method

<b>cl_gui_frontend_services=>GET_SYSTEM_DIRECTORY

cl_gui_frontend_services=>DIRECTORY_LIST_FILES- this will give Lists Files in a Given Directory</b>

Change the initial directory accordingly.

Message was edited by: Judith Jessie Selvi

0 Kudos

program below will show an 'X' if files in dir (drive) exist.

types: begin of ts_dir,

dir(1) type c,

end of ts_dir.

data: lt_dirs type table of ts_dir.

data: ls_dirs type ts_dir.

DATA: lv_dir type string.

DATA: lv_result type c length 1.

ls_dirs-dir = 'A'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'B'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'C'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'D'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'E'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'F'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'G'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'H'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'I'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'J'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'K'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'L'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'M'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'N'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'O'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'P'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'Q'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'R'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'S'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'T'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'U'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'V'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'W'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'X'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'Y'. append ls_dirs to lt_dirs.

ls_dirs-dir = 'Z'. append ls_dirs to lt_dirs.

loop at lt_dirs into ls_dirs.

concatenate ls_dirs-dir ':\' into lv_dir.

CALL METHOD cl_gui_frontend_services=>directory_exist

EXPORTING

directory = lv_dir

receiving

RESULT = lv_result

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

NOT_SUPPORTED_BY_GUI = 4

others = 5.

write: / lv_dir, lv_result.

endloop.

its not the nicest solution i think, but it works.

0 Kudos

Hi,

here's my work around:

DATA: sign.
DATA: BEGIN OF itab OCCURS 0,
        device TYPE string,
        size(16) TYPE i,
      END OF itab.
*
DO VARYING sign FROM sy-abcde(1) NEXT sy-abcde+1(1).
  CLEAR itab.
  IF sign <> space.
    CONCATENATE sign ':' INTO itab-device.
  ELSE.
    EXIT.
  ENDIF.

  CALL METHOD cl_gui_frontend_services=>get_free_space_for_drive
    EXPORTING
      drive                 = itab-device
    CHANGING
      free_space            = itab-size.

  CALL METHOD cl_gui_cfw=>flush.
  APPEND itab.

ENDDO.

LOOP AT itab WHERE size > 0.
  WRITE: / itab-device, itab-size.
ENDLOOP.

Andreas