  | 
		
HP COBOL Reference Manual
 
 
If you use the ADD or SUBTRACT statements with the CORRESPONDING
phrase, any individual operation can cause a size error condition. In
this instance, the imperative statement in the ON SIZE ERROR phrase
executes after all the individual additions or subtractions are
complete.
6.6.5 CORRESPONDING Phrase
 
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:
 
  - All identifiers must refer to group items.
  
 - The data description entries of these identifiers can contain a
  REDEFINES or OCCURS clause.
  
 - Identifiers can be subordinate to a data description entry that has
  a REDEFINES or OCCURS clause.
  
 - You cannot specify identifiers with level-number 66, 77 or 88, or
  the USAGE IS INDEX clause.
  
 - Identifiers cannot be reference-modified.
  
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.
 
  - Data items subordinate to both identifier-1 and
  identifier-2 must have the same data-name.
  
 - All possible qualifiers for a data item contained in
  identifier-1 (up to but not including identifier-1),
  must be identical to all possible qualifiers for the matching item in
  identifier-2 (up to but not including identifier-2).
  
 - In an ADD or SUBTRACT statement, the CORRESPONDING phrase affects
  only elementary numeric data items. Other data items do not take part
  in the operation.
  
 - In a MOVE statement, either the sending or receiving subordinate
  item can be a group item, but both cannot be. The classes of the data
  items in any corresponding pair can be different, but the resulting
  move must be legal according to the MOVE statement rules. (See the
  Section 6.8.22 statement.)
  
 - The CORRESPONDING phrase disallows data items with the following:
  
    - Level-number 66
    
 - Level-number 88
    
 - A data description entry containing a REDEFINES, OCCURS, or USAGE
    IS INDEX clause
  
  
     A data item subordinate to one that is not eligible for
    correspondence is also disallowed.
   - FILLER data items and their subordinates are disallowed.
  
 - Neither identifier-1 nor identifier-2 can be reference modified.
  
6.6.6 ON EXCEPTION Phrase
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:
 
  - The imperative statement associated with the ON EXCEPTION phrase is
  executed.
  
 - The NOT ON EXCEPTION phrase, if specified, is ignored.
  
 - Control is transferred to the end of the statement unless control
  has been transferred by executing the imperative statement of the ON
  EXCEPTION phrase.
  
When an exception condition occurs and the statement does not contain
an ON EXCEPTION phrase:
 
  - The NOT ON EXCEPTION phrase, if specified, is ignored.
  
 - The program terminates abnormally.
  
When an exception condition does not occur:
 
  - The imperative statement associated with the NOT ON EXCEPTION
  phrase, if specified, is executed.
  
 - The ON EXCEPTION phrase, if specified, is ignored.
  
 - Control is transferred to the end of the statement unless control
  has been transferred by executing the imperative statement of the NOT
  ON EXCEPTION phrase.
  
6.6.7 Overlapping Operands and Incompatible Data
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:
 
  - Determine whether or not an item contains numeric or alphabetic
  data.
  
 - Specify corrective action when it does not.
  
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:
 
  - CLOSE
  
 - DELETE
  
 - OPEN
  
 - READ
  
 - REWRITE
  
 - START
  
 - UNLOCK
  
 - WRITE
  
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--Hewlett-Packard 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
 
 
Status Key 1 indicates one of the following conditions when an
input-output operation ends:
 
  - Successful Completion. The input-output statement executed
  successfully.
  
  - At End. A sequential READ statement unsuccessfully executed because
  of the following:
  
    - The file has no next logical record.
    
 - An optional file was not present.
    
 - The program did not establish a valid next record.
  
  
  
  - Invalid Key. The input-output statement executed unsuccessfully
  because of one of the following conditions:
  
    - Sequence Error
    
 - Duplicate Key
    
 - No Record Found
    
 - Boundary Violation on a relative or indexed file
    
 - Optional File Not Present
  
  
  
  - Permanent Error. The input-output statement executed unsuccessfully
  because of a boundary error for a sequential file. This value can also
  indicate an input-output error, such as data check, parity error, or
  transmission error.
  
  -  Logic Error. The input-output statement was unsuccessfully
  executed as a result of an improper sequence of input-output operations
  that were performed on the file or as a result of violating a limit set
  by the user.
  
  - Hewlett-Packard defined. The input-output statement executed
  unsuccessfully because of a condition defined by Hewlett-Packard.
  
Status Key 2
 
 
Status Key 2 further describes the result of the input-output operation
as follows:
 
  - If no further information about the input-output operation is
  available, Status Key 2 contains 0.
  
 - When Status Key 1 contains 0 (indicating
  successful completion), Status Key 2 can contain a 2,
  4, 5, or 7.
  
    - Applies to a REWRITE, WRITE, or READ statement.
    
      -  For REWRITE and WRITE statements it means that the record just
      written created a duplicate key value for at least one alternate record
      key for which duplicates are allowed.
      
 -  For READ statements it means that the record just read has
      duplicate key values for the current key of reference.
    
  
    
  
    - Applies to a READ statement. It means the size of the record read
    does not agree with the size defined in the program.
  
  
  
    - Applies to the OPEN statement. It means that the optional file was
    not present when the OPEN statement executed. If the open mode is I-O
    or EXTEND, the file has been created.
  
  
  
    - Applies to the CLOSE and OPEN statements. It means one of the
    following:
    
      - The program tried to execute a CLOSE REEL/UNIT, a CLOSE NO REWIND,
      or a CLOSE FOR REMOVAL statement for a file on a nonreel/unit medium.
      
 - The program tried to execute an OPEN NO REWIND statement for a file
      on a nonreel/unit medium.
    
  
    
   - When Status Key 1 contains 1 (indicating an at end
  condition), Status Key 2 describes the condition's cause:
  
    - Indicates that the file has no next logical record or it indicates
    that a file you specified as optional is not present.
  
  
  
    - Means that the relative record number of the record read was too
    big for the relative key data item.
  
  
   - When Status Key 1 contains 2 (indicating an
  invalid key condition), Status Key 2 describes the condition's cause as
  follows:
  
    - Indicates a sequence error for a sequential access indexed file.
    This means that the program changed the prime record key value between
    a successfully executed READ statement and the next REWRITE statement
    for the file. This value can also indicate that the program violated
    sort order sequence requirements for successive record key values. (See
    the Section 6.8.43 statement.)
  
  
  
    - Indicates a duplicate key value. The program tried to write or
    rewrite a record that would have created a duplicate key in an indexed
    file. This value can also mean that the program tried to write a record
    that would have created a duplicate in a relative file.
  
  
  
    - Means that the program could not find a record. The program tried
    to access a record identified by a key, but the record does not exist
    in the file, or the file you specified as optional is not present.
  
  
  
    - Indicates a boundary violation. The program tried to write beyond
    the boundaries defined for the file by the I/O system (OpenVMS Alpha
    Record Management Services (RMS) on OpenVMS Alpha systems), or the
    program attempted a sequential WRITE statement and the number of
    significant digits in the relative record number is larger than the
    size of the relative key data item.
  
  
   - When Status Key 1 contains 3 (indicating a
  permanent error condition), Status Key 2 describes the condition causes
  as follows:
  
    - Indicates that no more information is available. This value results
    from any input-output error that cannot be described by any other
    combination of values in Status Keys 1 and 2. For example, "filename
    too long" is indicated this way.
  
  
  
    - Indicates a boundary violation on a sequential file. This means
    that the program tried to write to a disk that was full.
  
  
  
    - Indicates that the program tried to open a file that does not exist.
  
  
  
    - Indicates that the program tried to create a file on a device that
    is not appropriate for the OPEN statement mode.
  
  
  
    - Indicates that the program tried to open a file that is closed with
    a lock.
  
  
  
    - Indicates a conflict of file attributes. The attributes of the file
    that the program attempted to open do not match the attributes of the
    file described in the program. The attributes that are checked are
    BLOCK SIZE, ORGANIZATION, INDEX KEYS, and MAXIMUM RECORD SIZE. (Refer
    to the Tru64 UNIX reference page or COBOL online help for
    information on the effect of the relaxed key checking option.)
  
  
  
  - When Status Key 1 contains 4 (indicating an error
  in the program's logic), Status Key 2 describes the condition's cause: )
  
    - Indicates that the program tried to open a file that is already
    open.
  
  
  
    - Indicates that the program tried to close a file that either: (a)
    is already closed, or (b) has not been opened during the program's
    execution.
  
  
  
    - Indicates that the program tried to execute either: (a) a DELETE or
    REWRITE statement without first successfully executing a READ or START
    statement, or (b) an UNLOCK RECORD statement without first establishing
    a current record.
  
  
  
    - Indicates that the program attempted to REWRITE a record that is
    not the same size as the record being replaced.
  
  
  
    - Indicates that the program did not establish a valid next record.
    
 The values 10 and 46 can occur for the same READ operation when a
    program is in an infinite loop. In this case, the FILE STATUS data item
    contains the following sequence of values:  00, 00, ... , 00, 10,
    46, 46, ... , 46
    
  
    - Indicates the program tried a READ or START operation on a file
    that: (a) has not been opened, or (b) has been opened in a mode that is
    incompatible with the operation.
  
  
  
    - Indicates the program attempted a WRITE operation on a file that:
    (a) has not been opened, or (b) has been opened in a mode that is
    incompatible with the operation.
  
  
  
    - Indicates the program tried a DELETE or REWRITE on a file that: (a)
    has not been opened, or (b) has been opened in a mode that is
    incompatible with the operation.
  
  
   - When Status Key 1 contains 9 (indicating a
  Hewlett-Packard defined condition), Status Key 2 further describes the
  condition, as follows:
  
    - Means that the record your program is reading has been locked by
    another access stream. Because the record is available in the record
    area, the input operation is successful. This condition results from
    using the REGARDLESS option. Without the REGARDLESS option, the same
    scenario causes a Status Key 2 value of 2.
  
  
  
    - Indicates that a file is locked. The access stream tried to open a
    file that had been locked by another program.
  
  
  
    - Means that a record is locked. The program tried to access a record
    that had been locked by another access stream. 
 In this case, the
    record is not available in the record area, so the input operation is
    unsuccessful.
    
  
    - Means that the program tried to open a file when there was not
    enough space on the device.
  
  
  
    - Indicates that an unspecified error occurred when the program
    attempted to close a file.
  
  
  
 
  
  
		   |