Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

delete dataset command

Former Member
0 Likes
6,885

hi everybody

does delete dataset command work in background mode?

wen i execute my program in foreground, the dataset is deleted but when it is run in background mode, its not deleted

5 REPLIES 5
Read only

Former Member
2,927

I am using delete dataset command and able to delete dataset using both foreground and background.

Please refer below code for your reference.

open dataset p_file for output in text mode

encoding default.

delete dataset p_file.

close dataset p_file.

Thank you

Seshu

Read only

Former Member
0 Likes
2,927

Hi,

It will delete the dataset in the Background too. Before using this statement the check the file exists in AL11. and even check after the statement exeution.

Read only

Former Member
0 Likes
2,927

Hi Anjali,

Deleting a File

To delete a file from the application server, use the DELETE DATASET statement:

Syntax

DELETE DATASET <dsn>.

This statement deletes the file <dsn>. The naming convention is described in the section Opening a File.

If the system deletes the file <dsn> successfully, SY-SUBRC is set to 0. If not, it is set to 4.

The followinng code will make it clear that it works both foreground and background

DATA FILENAME(60) VALUE 'FILETEST'.

OPEN DATASET FILENAME FOR OUTPUT.

OPEN DATASET FILENAME FOR INPUT.

IF SY-SUBRC = 0.
  WRITE / 'File found'.
ELSE.
  WRITE / 'File not found'.
ENDIF.

DELETE DATASET FILENAME.

OPEN DATASET FILENAME FOR INPUT.

IF SY-SUBRC = 0.
  WRITE / 'File found'.
ELSE.
  WRITE / 'File not found'.
ENDIF.

The output appears as follows:

File found

File not found

P.S Syntax source is from help.sap.com

Revert for further clarification.

Thanks and Regards

Srikanth.P

Read only

Former Member
0 Likes
2,927

Make sure you are closing dataset. Also try WAIT after CLOSE DATASET command.

Check sy-subrc code. Do F1 on DELETE DATASET Command to understand sy-subrc return values.

Read only

0 Likes
2,927

thanks everyone