Closing a File Locate the document in its SAP Library structure

To close a file on the application server, use the close statement.

Syntax

CLOSE DATASET <dsn>.

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

You only need to close a file if you want to delete its contents the next time you open it for write access. For further information and an example, refer to Opening a File for Write Access.

Note

However, to avoid errors, and to make your programs easier to read, you should always close a file before the next OPEN DATASET statement. The CLOSE statement divides your program into logical blocks, and makes them easier to maintain.

Example

DATA FNAME(60) VALUE 'myfile'.

OPEN DATASET FNAME FOR OUTPUT.
  .....
CLOSE FNAME.

OPEN DATASET FNAME FOR INPUT.
  .....
CLOSE FNAME.

OPEN DATASET FNAME FOR INPUT AT POSITION <pos>.
  .....
CLOSE FNAME.

The CLOSE statement is not obligatory in this example, but it does improve the layout of the program.

 

 

 

 

 

Leaving content frame