COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
prohibited for a file whose access mode is sequential) when there is no USE procedure that
applies to the file.
imperative-stmt-2
is an imperative statement to be executed (after a declarative procedure) when no exception
or an exception other than the invalid-key condition arises during the delete operation.
END-DELETE
ends the scope of the DELETE statement and makes it a delimited-scope statement. If you omit
END-DELETE but include the INVALID KEY or NOT INVALID KEY phrase, the DELETE statement
is a conditional statement and ends at the next period separator.
Usage Considerations:
• I-O Status Codes
If the file being closed has an associated file-status data item, the DELETE statement assigns it
an appropriate I-O status code. The possible I-O status codes and their meanings are:
MeaningI-O Status Code
The delete operation was successful.“00”
The designated record does not exist.“23”
The delete operation failed due to causes outside of COBOL. The specified record
might or might not have been deleted. The file position indicator might be undefined.
“30”
The delete operation failed because the last input-output statement executed for the
file (which is in the sequential access mode) was not a successfully executed READ
statement.
“43”
The file was not open in the I-O mode or was not opened by an HP COBOL
program.
“49”
When the deletion is successful or the invalid-key condition occurs, these items are not affected:
◦ Record area
◦ Data item specified in the DEPENDING phrase of the RECORD clause, specifying the
length of the record
◦ Key of reference
◦ File position indicator
• Record Deleted When File Access Mode is Sequential
If the file’s access mode is sequential and the last operation performed on the file was a
successful READ statement, then DELETE logically removes from the file the record that the
READ statement retrieved. If the last operation performed on the file was not a successful READ
statement, DELETE terminates with I-O status code “43.”
In a Pathway environment under the NonStop Transaction Management Facility (TMF), the
last operation on the file must have been a successful execution of a READ LOCK statement
(rather than a READ statement). For information on coding servers, see the Pathway/TS SCREEN
COBOL Reference Manual for your system.
The record retrieved by the READ statement is deleted.
• Record Deleted When File Access Mode is Random or Dynamic
If the file’s access mode is random or dynamic, the record to be deleted is defined by the
record key, or, for relative files, the relative key (indexed or prime key). If the designated
record does not exist, an invalid-key condition occurs with I-O status code “23.”
DELETE 311










