‎2009 May 19 12:53 PM
Hi
I want to delete the csv file from the application server once the full data set is read.
i am sucessful to read the data set,but while usiong the delete datset,its deleting it,but as next time i am not abale to read any data,but file exits on application server.
please tell me how to delete file physicaly from application server too.
seconding,how to write the data from my tabel to csv file in application server.
my code for deleteing file:
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DELETE DATASET file.
CLOSE DATASET file.
code for writing the data to file:
OPEN DATASET file1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT result.
CLEAR:wa1.
CONCATENATE result-mat1 ',' result-mat2 ',' result-type ',' result-message INTO wa1.
*
TRANSFER wa1 TO file1.
IF sy-subrc = 0.
ENDIF.
*
ENDLOOP.
TRANSFER result TO file1.
CLOSE DATASET file1.
‎2009 May 19 1:00 PM
WS_FILE_DELETE - "Delete File at the Frontend or Presentation server file
or
EPS_DELETE_FILE "Application file delete
delete file
DELETE DATASET FILE_PATH. "File_path is nothing but appl file name
IF SY-SUBRC <> 0.
RAISE DELETE_FAILED.
ENDIF.
‎2009 May 19 1:12 PM
The one whos writing the file does not set the correct authorities (chmod).
‎2009 May 19 1:13 PM
Hi,
For deleteing dataset it is not required to open and close the dataset:
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
READ DATASET...
CLOSE DATASET file.
DELETE DATASET file.
ENDIF.For writing the data to file in CSV format you need to use the concatenate statement and to insert the comma between the fields:
OPEN DATASET file1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT result.
CLEAR:wa1.
CONCATENATE result-mat1 result-mat2 result-type result-message INTO wa1 SEPRATED By ','.
TRANSFER wa1 TO file1.
ENDLOOP.
CLOSE DATASET file1.