‎2008 May 05 10:55 AM
Hi ,
Can anyone tell me how to use CL_GUI_FRONTEND_SERVICES=>File_Copy method to move a file from one folder to another.
‎2008 May 05 11:09 AM
Hope below example code can help you understand in using the class CL_GUI_FRONTEND_SERVICES:
TYPE-POOLS: abap.
PARAMETERS: p_file1 TYPE filename OBLIGATORY,
p_file2 TYPE filename OBLIGATORY.
DATA: l_ret TYPE abap_bool,
l_suc TYPE i.
DATA: l_file1 TYPE string,
l_file2 TYPE string.
START-OF-SELECTION.
MOVE: p_file1 TO l_file1,
p_file2 TO l_file2.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_file1
RECEIVING
result = l_ret
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc EQ 0.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = l_file1
DESTINATION = l_file2
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.
IF sy-subrc EQ 0.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = l_file1
CHANGING
rc = l_suc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8
OTHERS = 9.
IF sy-subrc EQ 0.
WRITE: 'File:', p_file1, ' successfully copied to: ',
p_file2.
ENDIF.
ENDIF.
ENDIF.
‎2008 May 05 11:24 AM