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: 

How to get he names of all the local drives that are present in hdd

Former Member
0 Kudos
126

Hi ABAP Experts,

I want to get the names of all the local drives that are present in hdd on local system using

ABAP. Is this technically possible. If so how.

Thanks & Regards,

Aexandr Ciunchik

8 REPLIES 8

Former Member
0 Kudos
78

Hi,

Check with the CLASS <b>CL_GUI_FRONTEND_SERVICES</b> there are methods like.

<b>DIRECTORY_BROWSE

DIRECTORY_GET_CURRENT</b>

Regards,

AS

0 Kudos
78

<b>Arun Sambargi</b>,

thank you! Bad I need to get table with existing drives on my computer. Therefore those functins are not suitable for me. Maybe, is there another way to help me?

Former Member
0 Kudos
78

Hello,

Try with the Tcode RZ20.

If useful reward.

Vasanth

Former Member
0 Kudos
78

There may be no good solution.

But you can enumerate all drivers by query the driver's property.

Former Member
0 Kudos
78

Hi Alexandr,

Check this reply(Peters and Andreas) in this thread.

A workaround, get all the drive names(A - Z) and then check <b>cl_gui_frontend_services=>directory_exist</b>.

Regards,

AS.

0 Kudos
78

hi,

try that:

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

Former Member
0 Kudos
78

Hi Alexandr,

My workaround.


REPORT zztest.

DATA : len          TYPE i,
       off          TYPE i,
       directory    TYPE string,
       result(1).

len = STRLEN( sy-abcde ).

DO len TIMES.

  off = sy-index - 1.

  CONCATENATE sy-abcde+off(1) ':' INTO directory.

  CONDENSE directory NO-GAPS.


  CALL METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
      directory            = directory
    RECEIVING
      result               = result
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 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.

  IF result EQ 'X'.
    WRITE : / 'Drive : ',
              directory.
  ENDIF.

ENDDO.


Regards,

AS

0 Kudos
78

Thanks! You really help me!