Previous | Contents | Index |
The CORRESPONDING phrase allows you to specify group items as operands in order to use their corresponding subordinate items in an operation. See the Section 6.8.2 , Section 6.8.37 , and Section 6.8.22 statements.
The following rules apply to the identifiers of operands in a statement containing the CORRESPONDING phrase:
The following rules describe the requirements for correspondence between data items subordinate to the identifiers. In these rules, identifier-1 refers to the sending group item and identifier-2 refers to the group in which results of the operation are stored.
The ON EXCEPTION phrase allows execution of an imperative statement when an exception (or error) condition occurs.
The NOT ON EXCEPTION phrase allows execution of an imperative statement when an exception condition (or any other error condition) does not occur.
The format is as follows:
stment is an imperative statement.
The ON EXCEPTION phrase of the CALL statement prevents control transfer of the CALL and triggers the execution of the imperative statement related to the CALL.
The ON EXCEPTION phrase of the ACCEPT statement (Formats 3 and 4) allows you to handle data entry errors when data is accepted into a numeric data field using ACCEPT WITH CONVERSION. For additional information, see the Section 6.8.1 statement.
The ON EXCEPTION phrase allows execution of an imperative statement when an ACCEPT statement (Format 5) terminates unsuccessfully. When there is an applicable CRT STATUS clause, unsuccessful termination is indicated by a value of '1' or '9' in the first character of the CRT STATUS data item (see the SPECIAL-NAMES section of Chapter 4).
When an exception condition occurs and the statement contains an ON EXCEPTION phrase:
When an exception condition occurs and the statement does not contain an ON EXCEPTION phrase:
When an exception condition does not occur:
When statements refer to data items, two conditions can occur that can make program results unpredictable.
Undefined results occur when a sending and receiving item in an arithmetic statement or an INITIALIZE, INSPECT, MOVE, SET, STRING, or UNSTRING statement share a part of their storage areas.
Procedure Division references to a data item are undefined when a data item's contents are incompatible with the class of data defined by the item's PICTURE clause, or (if the item is a function) its function definition. Conditional statements containing the class condition allow you to do the following:
See Section 6.5.2 for more information on class condition.
6.6.8 I-O Status
If a file description entry has a FILE STATUS clause, a value is placed in the two-character FILE STATUS data item during execution of the following I/O statements:
The two characters from the FILE STATUS data item combine to form a file status value. The first character (Status Key 1), which occupies the leftmost character position in the item, represents a specific class of I/O operation (0--success, 1--at end, 2--invalid key, 3--permanent error, 4--logic error, or 9--Compaq defined). The second character (Status Key 2), which occupies the rightmost position, provides additional information about the result of an I/O operation. In combination, Status Key 1 and Status Key 2 indicate the status of an I/O operation. For example, if you are interested in duplicate keys, you check for File Status 02.
When Status Key 1 contains 1, the AT END phrase executes. When Status Key 1 contains 2, the INVALID KEY phrase executes. When Status Key 1 contains 3, 4, or 9 the Declarative USE procedure executes. Any applicable USE AFTER EXCEPTION procedure executes after the FILE STATUS value is set.
Figure 6-1 shows the possible combinations of Status Keys 1 and 2. In the figure, X indicates a valid combination of keys.
Figure 6-1 Possible Combinations of Status Keys 1 and 2
Status Key 1 indicates one of the following conditions when an input-output operation ends:
Status Key 2 further describes the result of the input-output operation as follows:
Appendix C lists all the possible file status values that can appear
in the FILE STATUS data item, along with the I-O status condition
corresponding to each value.
6.6.9 AT END Phrase
The AT END phrase specifies the action your program takes when an at end condition occurs (when Status Key 1 contains 1).
The NOT AT END phrase specifies the action your program takes if an at end (or any other error condition) does not occur.
The format is as follows:
stment is one or more imperative statements.
When a program detects the end of a file, the condition is called the at end condition. The at end condition might occur as a result of ACCEPT, READ, RETURN, or SEARCH statement execution. (For additional information, see the previously mentioned statements.)
When an at end condition occurs and the statement contains an AT END phrase:
When an at end condition occurs and the statement does not contain an AT END phrase:
When an at end condition does not occur, and no other exception condition exists:
When an at end condition does not occur, and another exception condition does exist:
The INVALID KEY phrase specifies the action your program takes when an invalid key condition is detected (when Status Key 1 contains 2) for the file being processed.
The NOT INVALID KEY phrase specifies the action your program takes when an invalid key condition (or any other error condition) is not detected for the file being processed.
The format is as follows:
stment is one or more imperative statements.
The invalid key condition occurs when the I/O system cannot complete a COBOL DELETE, READ, REWRITE, START, or WRITE statement because of one of the following conditions:
(For more information on these conditions, refer to Section 6.6.8.) When the invalid key condition occurs, execution of the statement that produced the condition is unsuccessful, and the file is unaffected. (For additional information, see the previously mentioned statements.)
When the invalid key condition occurs:
When an invalid key condition does not occur, and no other exception condition exists:
When an invalid key condition does not occur, and another exception condition does exist:
record-name and identifier must not refer to the same storage area.
The result of executing a RELEASE, REWRITE, or WRITE statement with the FROM phrase is equivalent to: (1) executing the statement "MOVE identifier TO record-name" according to the rules of the MOVE statement without the CORRESPONDING phrase, followed by (2) executing the same RELEASE, REWRITE, or WRITE statement without the FROM phrase.
After statement execution ends, the data in the area referenced by
identifier is available to the program. The data is not
available in the area referenced by record-name, unless there
is an applicable SAME clause. (See Section 4.2.10, I_O_CONTROL, the Section 6.8.30
statement, and the Section 6.8.43 statement.)
6.6.12 INTO Phrase
The INTO phrase implicitly moves a current record from the record storage area into an identifier.
The format is as follows:
A READ or RETURN statement can have the INTO phrase if either of the following conditions is true:
Executing a READ or RETURN statement with the INTO phrase is equivalent to: (1) executing the same statement without the INTO phrase, then (2) moving the current record from the record area to the area specified by identifier. The move occurs according to the rules of the MOVE statement without the CORRESPONDING phrase. The move does not occur for an unsuccessful execution of the READ or RETURN statement.
Subscript or index evaluation occurs after the input operation and immediately before the move.
The record is available to the program in both the record area and the area associated with the identifier.
Previous | Next | Contents | Index |