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.
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.
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.