09-15-2008 5:43 PM
In our requirement, we have an excel file in Local pc(in network). We want to delete this excel file from R/3 .
Is their any RFC/BAPI for deleting this excel file.Could you suggest any?
09-15-2008 5:57 PM
Check class cl_gui_frontend_services, methods DIRECTORY_LIST_FILES and FILE_DELETE.
Regards,
Valter Oliveira
09-15-2008 5:57 PM
Check class cl_gui_frontend_services, methods DIRECTORY_LIST_FILES and FILE_DELETE.
Regards,
Valter Oliveira
09-15-2008 6:07 PM
Thanks, can you suggest any function module/BAPI which can retrieve this deleted excel file again on the same path.
09-15-2008 6:17 PM
For that I would create a "backput directory" and use method FILE_COPY of the same class. Before delete, copy the files to this directory. To undo delete, copy from this directory to the starting place.
Regards,
Valter Oliveira.
09-16-2008 11:55 AM
Could you please advice some RFCs/BAPI name in place of classes and their methods.... It would be more helpful to us.
09-16-2008 12:09 PM
I could suggest you FM GUI_DELETE_FILE that probably do the same.
But please don't be "afraid" of method. They are faster than function modules. Check this example.
CLASS cl_gui_frontend_services DEFINITION LOAD.
DATA: data_tab TYPE STANDARD TABLE OF file_info.
DATA: wa TYPE file_info.
DATA: w_count TYPE i.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = p_dirin
files_only = 'X'
directories_only = space
CHANGING
file_table = data_tab
count = w_count.
IF sy-subrc NE 0.
EXIT.
ENDIF.
LOOP AT data_tab INTO wa.
CONCATENATE p_dirin wa-filename INTO w_filename.
CONCATENATE p_dirout wa-filename INTO w_copyout.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = w_filename
DESTINATION = w_copyout
overwrite = 'X'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
disk_full = 4
access_denied = 5
file_not_found = 6
destination_exists = 7
unknown_error = 8
path_not_found = 9
disk_write_protect = 10
drive_not_ready = 11
not_supported_by_gui = 12
OTHERS = 13.
CHECK sy-subrc EQ 0.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = w_filename
CHANGING
rc = w_rc.
ENDLOOP.
Regards,
Valter Oliveira.