@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 |
CODE= | The operand controls the character set in which the work file is to be written. If the operand is not specified and if the character set of the SAM file, ISAM
is output. If the user responds |
name | Character set that is to be used for writing. The name of a valid character |
*FILE | Before the write operation, the work file is converted into the character set |
*EDT | The work file's character set is used for writing irrespective of whether any |
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.