Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

@CLOSE - Write back and close a file

&pagelevel(3)&pagelevel

@CLOSE may be used to write back an open file, close this file and then delete the work file.

Operation

Operands

F mode, L mode

@CLOSE

[ { N OWRITE |  C ODE={name | * E DT | * F ILE } } ]

NOWRITE

The work file is deleted and is not written back. The opened file or library
element is closed unchanged. If a file has been opened for real processing
in work file 0 (see @OPEN, format 2) then NOWRITE has no effect.

CODE=

The operand controls the character set in which the work file is to be written.
In the case of a file opened for real processing in work file 0 the operand
has no effect.

If the operand is not specified and if the character set of the SAM file, ISAM
file or library element or the character set used when opening a POSIX file
differs from that of the work file then, in batch mode, the message EDT5457
is output, no write operation is performed and the file remains open. In
interactive mode, the query

% EDT0915 CONVERT TO FILE CCS (&00)? REPLY (Y=YES; N=NO)?

is output. If the user responds Y then a conversion to the file's character set
is performed before the write operation. If the user responds N then the work
file's character set is used.

name

Character set that is to be used for writing. The name of a valid character
set must be specified (see section “Character sets”).

*FILE

Before the write operation, the work file is converted into the character set
of the existing SAM file, ISAM file or library element or into the character set
used when opening a POSIX file. If this character set was *NONE then
EDF03IRV is used.

*EDT

The work file's character set is used for writing irrespective of whether any
file that may exist has a different character set.

The @CLOSE statement is rejected with error message EDT5177 if the current work file does not contain a file or library element opened with @OPEN or @XOPEN.

After the close operation, the character set used for writing is entered in the catalog for SAM files, ISAM files and library elements.

If the work file is converted before writing and if it contains characters which are invalid in the character set used by the file that is to be written then these characters are replaced by a substitute character provided that such a character has been specified (see @PAR SUBSTITUTION-CHARACTER); otherwise, the file is not written, it remains open and error message EDT5453 is output. The user can then define a substitute character or modify the character set for writing and run @CLOSE again.

If the work file contains lines that are too long for the file that is to be written (e.g. if the file has a fixed record length) or if the conversion operation creates any such records (possible in the case of Unicode character sets), then the write operation is aborted with the message EDT5444.

When ISAM files are written, the ISAM key is formed from the line number if
KEY=LINENUMBER or KEY=IGNORE was specified when the file was opened. If KEY=DATA was specified when the file was opened then the ISAM key is taken over from the data area. In this case, the user must make sure that the sequence of work file records corresponds to the sequence of ISAM keys as otherwise the write operation will be rejected with the message EDT4208 (DMS error code 0AAB).

The definition of any secondary keys in an ISAM file (in a secondary index) is retained after @CLOSE unless the key fields have been modified inconsistently in the data area. In this case, the message EDT5246 is output and the secondary index is deleted.

If, during the processing of an opened ISAM file, the character set is changed either from or to UTF16 or if this occurs implicitly due to a corresponding specification in the CODE operand then the file cannot be written back since this would modify the length of the key field. In this case, the @CLOSE statement is rejected with the error message EDT5468.

After a SAM or ISAM file has been closed with @CLOSE, EDT usually releases the file's no longer required disk storage space. However, this can be prevented by setting
job switch 7.

If the current version number was specified when an ISAM file was opened for real processing (see @OPEN, format 2) whereas the AS operand was not specified then the current version number (which has been incremented by 1) is displayed after @CLOSE.

If the statement is interrupted with [K2] and the EDT session is continued with /INFORM-PROGRAM then the processing of the statement is aborted and message EDT5501 is output.

Note

When @CLOSE is run, an implicit @DELETE (format 2) is executed for the current work file. This resets a number of work file properties to their initial values.

Example

@OPEN FILE=FILE1 ------------------------------------------------------ (1)
<EDT statements> ------------------------------------------------------ (2)
@CLOSE CODE=UTFE ------------------------------------------------------ (3)

(1) The file FILE1 is opened and read into the current work file in the file's character set.

(2) The current work file is processed.

(3) The file FILE1 is opened and read into the current work file in the file's character set.

In the BS2000 catalog, FILE1 is assigned the attribute CODED-CHARACTER-SET=UTFE. The current work file is deleted.