The sequential organization input-output statements in the Procedure Division are the CLOSE, DELETE FILE, OPEN, READ, REWRITE, UNLOCK and WRITE statements.
Sequential organization input-output provides a capability to access records of a file in an established sequence. The sequence is established as a result of writing the records to the file.
Sequential files are organized such that each record in the file except the first has a unique predecessor record, and each record except the last has a unique successor record. These predecessor-successor relationships are established by the order of WRITE statements when the file is created. Once established, these relationships do not change except when records are added to the end of the file.
Only the sequential access mode is available for files whose organization is sequential. In the sequential access mode, the sequence in which records are accessed is the order in which the records were originally written.
File Position Indicator
The file position indicator is a concept used to facilitate specification of the next record to be accessed within a given file during certain sequences of input-output operations. The concept of the file position indicator has no meaning for a file opened in the output or extend mode. The setting of the file position indicator is affected only by the CLOSE, OPEN and READ statements.
If the FILE STATUS clause is included in a file control entry, it defines a two-character file status data item for that file. During the execution of each input-output statement that refers to such a file, the runtime system stores a value into the file status data item. Storage of the value is done before the execution of any associated imperative statement and before any applicable USE procedure is executed. The value can be used by the program to determine the status of that input-output operation. The value that is stored into the file status data item is called the I-O status value.
The I-O status value indicates the status of an input-output operation.It also determines whether an applicable USE procedure should be executed if one of the conditions listed under the heading “Successful Completion” results, an applicable USE procedure is not executed; if any other condition results, such a procedure may be executed depending on rules stated in the section of this chapter that discusses the USE statement.
Certain classes of I-O status values indicate critical error conditions. They are the ones that begin with the digits 3, 4 and 9. When such conditions arise, certain system- standard error correction procedures may be tried first, depending on the nature of the problem. If they are not successful in clearing the problem, either a user-specified USE procedure is executed (if one is applicable) and execution of the program continues, or a runtime error message is produced and execution of the run unit terminates.
Upon completion of the input-output operation, the I-O status value expresses one of the following conditions:
It should be noted that the I-O status values specified here differ in many respects from the ones defined in earlier versions of RM/COBOL. The new values comply with the American National Standard COBOL 1985 whereas the old values comply with ANSI COBOL 1974. In the following list, the old values are shown in square brackets following the new values when the two values are not the same. In situations where it is necessary to preserve compatibility with earlier versions of RM/COBOL in this respect, two courses of action are possible: either modify the text of the source program to use the new set of status values, or make use of the Compile Command option that causes the compiler to treat the entire program as an ANSI COBOL 1974 program.
The following list shows the possible I-O status values that can arise as a result of executing an input-output statement that refers to a sequential file:
- I-O Status Value=04 .A READ statement executed successfully but the length of the record being processed does not conform to the fixed file attributes for the file.
- I-O Status Value=05.The input-output statement is successfully executed but the file is not present at the time the input-output statement is executed.
- I-O Status Value=07.The input-output statement executed successfully. However, for a CLOSE statement with the NO REWIND, REEL/UNIT, or FOR REMOVAL phrase or for an OPEN statement with the NO REWIND phrase, the referenced file is on a non-reel/unit medium.
I-O Status Value=10.A sequential READ statement is attempted and no next logical record exists in the file because the end of the file has been reached, or a sequential READ statement is attempted for the first time on an optional input file that is not present.
- I-O Status Value=30.A permanent error exists and no further information is available concerning the input-output operation.
- I-O Status Value=34.A permanent error exists because of an attempt to write beyond the externally defined boundaries of a sequential file.
- I-O Status Value=35 .A permanent error exists because an OPEN statement with the INPUT, I-O, or EXTEND phrase is attempted on a nonoptional file that is not present.
- I-O Status Value=37 [90, 95].A permanent error exists because an OPEN statement is attempted on a file that does not support the open mode specified in the OPEN statement, or a DELETE FILE statement refers to a protected file. For OPEN statements, the possible violations are as follows:
- I-O Status Value=38 .A permanent error exists because an OPEN or DELETE FILE statement is attempted on a file previously closed with lock.
- I-O Status Value=39 .An OPEN or DELETE FILE statement is unsuccessful because of an incompatibility between the fixed file attributes and the attributes specified for the file in the program.
- I-O Status Value=41 .An OPEN statement is attempted for a file that is already open, or a DELETE FILE statement is attempted for an open file.
- I-O Status Value=42 .A CLOSE statement is attempted for a file that is not open.
- I-O Status Value=43 .A REWRITE statement is attempted for a mass storage file, and the last input-output statement executed for the file was not a successfully executed READ statement.
- I-O Status Value=44 .A boundary violation exists either because of an attempt to write or rewrite a record whose length is longer or shorter than the limits established by the RECORD IS VARYING clause, or because of an attempt to rewrite a record that is not the same size as the record being replaced.
- I-O Status Value=46 .A sequential READ statement is attempted on a file open in the input or I-O mode and no valid next record has been established either because the preceding READ statement caused an at end condition, or because the preceding READ statement was unsuccessful for some other reason.
- I-O Status Value=47 [90, 91].A READ statement is attempted on a file not open in the input or I-O mode.
- I-O Status Value=48 [90, 91].A WRITE statement is attempted on a file not open in the output or extend mode.
- I-O Status Value=49 [90, 91]. A REWRITE statement is attempted on a file not open in the I-O mode.
- I-O Status Value=93.An OPEN statement is attempted on a file that is not available. The availability of a file is determined by several factors, including the lock mode.
- I-O Status Value=94.An OPEN statement is attempted at a time when there is insufficient available memory to provide the required supplementary input-output areas and control structures, or an OPEN statement is attempted for a file that has an attribute that is not supported, or an OPEN statement is attempted for a file that has file attributes that are inconsistent among themselves.
- I-O Status Value=97.A REWRITE or WRITE statement is attempted while the record area contains one or more characters that are not legal for a line sequential file after mapping through the applicable code set.
- I-O Status Value=98.Defective record structure has been found in the file.
- I-O Status Value=99.A READ or REWRITE statement is attempted that refers to a record locked by another concurrent user. ThisI-O status value is returned only when the referenced file has an associated file status data item and there is an applicable USE procedure; when this is not the case, the program waits for the record to become available.
At End Condition
The at end condition can occur as a result of the execution of a Format 1 READ statement. Details regarding the circumstances that cause an at end condition are presented in the discussion of the Format 1 READ statement.
If the at end condition arises, execution of the READ statement is unsuccessful and the positioning of the file is not changed. The NOT AT END phrase and its imperative statement, if present, are ignored, and the following actions occur:
If the at end condition does not arise for the execution of a READ statement, the AT END phrase and its associated imperative statement, if present, are ignored, and the following actions occur in the order shown:
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.