2010 Feb 14 6:36 PM
Hi All,
I am trying to delete file from application server (AL11) directory after processing using DELETE DATASET FILE is not working , after processing also file still exists.
My code is like this,
&----
*& Form backup_file
&----
The file has been processed. Go ahead and copy it to the
backup directory and delete it from the processing directory.
----
FORM backup_file .
DATA: lv_oldfile TYPE string,
lv_backup TYPE string,
l_rc TYPE i.
IF p_appl = 'X'. "Unix file
lv_oldfile = wa_files-filename.
Replace the directory name with the backup directory.
REPLACE p_dir IN wa_files-filename WITH p_back.
Tack date/time onto the end of the file name to avoid duplicate
files
CONCATENATE wa_files-filename
'_'
sy-datum
'_'
sy-uzeit
INTO wa_files-filename.
OPEN DATASET wa_files-filename FOR OUTPUT
IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
f_backup_error = 'X'.
EXIT.
ELSE.
Write the file contents to the new backup file.
LOOP AT itab_input INTO wa_input.
TRANSFER wa_input TO wa_files-filename.
ENDLOOP.
ENDIF.
Close the backup file.
CLOSE DATASET wa_files-filename.
Delete the original file from the processing directory.
if sy-subrc = 0.
DELETE DATASET lv_oldfile.
endif.
endform.
Thanks Everyone!
2010 Feb 14 7:24 PM
Check the value of sy-subrc after delete statement.
Check whether you have authorization for delete
check link:[http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d5c358411d1829f0000e829fbfe/content.htm]
Hi All,
I am trying to delete file from application server (AL11) directory after processing using DELETE DATASET FILE is not working , after processing also file still exists.
My code is like this,
&----
*& Form backup_file
&----
The file has been processed. Go ahead and copy it to the
backup directory and delete it from the processing directory.
----
FORM backup_file .
DATA: lv_oldfile TYPE string,
lv_backup TYPE string,
l_rc TYPE i.
IF p_appl = 'X'. "Unix file
lv_oldfile = wa_files-filename.
Replace the directory name with the backup directory.
REPLACE p_dir IN wa_files-filename WITH p_back.
Tack date/time onto the end of the file name to avoid duplicate
files
CONCATENATE wa_files-filename
'_'
sy-datum
'_'
sy-uzeit
INTO wa_files-filename.
OPEN DATASET wa_files-filename FOR OUTPUT
IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
f_backup_error = 'X'.
EXIT.
ELSE.
Write the file contents to the new backup file.
LOOP AT itab_input INTO wa_input.
TRANSFER wa_input TO wa_files-filename.
ENDLOOP.
ENDIF.
Close the backup file.
CLOSE DATASET wa_files-filename.
Delete the original file from the processing directory.
if sy-subrc = 0.
DELETE DATASET lv_oldfile.
endif.
endform.
Thanks Everyone!
2010 Feb 14 7:24 PM
Check the value of sy-subrc after delete statement.
Check whether you have authorization for delete
check link:[http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d5c358411d1829f0000e829fbfe/content.htm]
2010 Feb 14 10:08 PM
Try to use OPEN DATA before using DELETE. Check this: http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d28358411d1829f0000e829fbfe/content.htm
Thanks
Satyasuresh Donepudi
2010 Feb 15 6:33 AM
HI,
You have to check the value of Sy-subrc after the delete statement,
and the value present in the variable lv_oldfile that if there is correct
value in the variable populated or not.
Moreover after assigning the value to variable lv_oldfile in the step
lv_oldfile = wa_files-filename.
then you should use this variable lv_oldfile only for open dataset and close dataset also.
Hope ir helps
Regards
Mansi
2010 Feb 15 6:38 AM
Hi Thanvi,
First open the dataset for output for lv_oldfile. and then use DELETE DATASET lv_old file.
You cannot delete the file unless you open the file for output.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |