‎2006 Feb 02 8:01 AM
Hi all,
Iam using following FM to retrive files in Aplln server.
OCS_GET_FILE_INFO.
Now my requirement if the length of file is 0 then i should delete the file.And Iam also submitting these files to another program for batchinput.
Kndly help me.
My code :
CALL FUNCTION 'OCS_GET_FILE_INFO'
EXPORTING
dir_name = p_path
file_name = gv_filter
TABLES
dir_list = gt_files
EXCEPTIONS
no_authority = 1
activity_unknown = 2
not_a_directory = 3
no_media_in_drive = 4
too_many_errors = 5
too_many_files = 6
bracket_error_in_filename = 7
no_such_parameter = 8
OTHERS = 9.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
SORT gt_files BY name.
REFRESH gr_name.
CLEAR gr_name.
gr_name-sign = 'I'.
gr_name-option = 'CP'.
gr_name-low = p_file.
APPEND gr_name.
LOOP AT gt_files WHERE type <> 'directory file'
AND name in gr_name.
IF p_withp = 'X'.
CONCATENATE p_path gt_files-name INTO gv_file.
ELSE.
gv_file = gt_files-name.
ENDIF.
REFRESH gt_params.
CLEAR gt_params.
gt_params-selname = p_sfile.
gt_params-kind = 'P'.
gt_params-low = gv_file.
APPEND gt_params.
IF NOT p_spath IS INITIAL.
CLEAR gt_params.
gt_params-selname = p_spath.
gt_params-kind = 'P'.
gt_params-low = p_path.
APPEND gt_params.
ENDIF.
IF p_repid = 'Y_WM_EINLAGERN_PRODUKTION'.
SUBMIT (p_repid) USING SELECTION-SET p_varid
WITH p_filn = p_path
WITH p_fil1 = gv_file
AND RETURN.
ELSE.
SUBMIT (p_repid) USING SELECTION-SET p_varid
WITH SELECTION-TABLE gt_params
AND RETURN.
ENDIF.
ENDLOOP.
In gt_files i have all the files.
ENDIF.
‎2006 Feb 02 8:03 AM
‎2006 Feb 02 8:04 AM
Hi,
I treid with that but its not workong
loop at gt_files where len eq 0.
delete dataset gt_files-name.
endloop.
and iam getting return code 4.
Message was edited by: Sai Chand Pullepu
‎2006 Feb 02 8:18 AM
for delete dataset to work, the important point is the file should be of character type.
convert the file to character type and try deleting
‎2006 Feb 02 8:22 AM
Hi,
gt_files-name is character type only.
But the gt_files contain the following structure
NAME
TYPE
LEN
OWNER
MTIME
ACC_MODE
MOD_DATE
MOD_TIME
‎2006 Feb 02 8:30 AM
‎2006 Feb 02 8:34 AM
hi,
Thanks for spending ur time.
anyway i solved with the following code.
Thanks anyway.
LOOP AT gt_files WHERE type <> 'directory file'
AND len EQ 0.
CONCATENATE p_path gt_files-name INTO test.
CONDENSE test NO-GAPS.
OPEN DATASET test.
IF sy-subrc EQ 0.
DELETE DATASET test.
IF sy-subrc EQ 0.
MESSAGE i000(0) WITH 'file deleted'.
ENDIF.
ENDIF.
ENDLOOP.