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: 

Regarding Frontend services class

Former Member
0 Kudos

Hi to all,

Can anybody tell me how to use

CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

The method returns all files in the specified directory.

Cheers.

...Reward if useful.

4 REPLIES 4

Former Member
0 Kudos

Hi,

The method returns all files in the specified directory.

Cheers.

...Reward if useful.

Former Member
0 Kudos

Hi,

we Can use this method cl_gui_frontend_services=>directory_list_files

to get the list of files not only from local server but also from a different server(other than R/3).

Check the sample code

REPORT ZGRO_TESTT.

*

DATA: FILE_TABLE TYPE FILETABLE.

DATA: COUNT TYPE I.

*

START-OF-SELECTION.

*

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

EXPORTING

DIRECTORY = 'C:\'

DIRECTORY = '
server\server1'

CHANGING

FILE_TABLE = FILE_TABLE

COUNT = COUNT.

*

IF SY-SUBRC 0.

WRITE: / SY-SUBRC.

ENDIF.

*

BREAK-POINT.

*

END-OF-SELECTION.

Reward useful Answers

Regards,

Raj.

Former Member
0 Kudos

TYPES: BEGIN OF TY_LINE,

LINE TYPE CHAR100,

END OF TY_LINE.

DATA: FILE_TABLE TYPE TABLE OF TY_LINE,

COUNT TYPE I.

CALL METHOD cl_gui_frontend_services=>directory_list_files

EXPORTING

directory ='C:\'

  • filter = '.'

  • files_only =

  • directories_only =

changing

file_table = FILE_TABLE

count = COUNT

  • EXCEPTIONS

  • cntl_error = 1

  • directory_list_files_failed = 2

  • wrong_parameter = 3

  • error_no_gui = 4

  • not_supported_by_gui = 5

  • others = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Reward if helpful

Former Member
0 Kudos

Hi,

check out the below sample code

DATA: gt_filetab TYPE TABLE OF file_info,

wa_filetab LIKE LINE OF gt_filetab,

lv_konyvtar_string TYPE string,

...

REFRESH gt_filetab.

lv_konyvtar_string = 'C:\Temp'

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

EXPORTING directory = lv_konyvtar_string

CHANGING file_table = gt_filetab

count = gv_count

Regards

Kiran Sure