The indexed organization input-output statements in the Procedure Division are the CLOSE, DELETE, DELETE FILE, OPEN, READ, REWRITE, START, UNLOCK and WRITE statements.
Indexed organization input-output provides the capability to access records of a mass storage file in either a random or sequential manner. Each record in an indexed organization file is uniquely identified by the value of one or more keys within that record, except when the DUPLICATES phrase is specified for all the keys associated with the file.
An indexed organization file is a mass storage file in which data records may be accessed by the value of a key. A record description may include one or more key data items, each of which is associated with an index. Each index provides a logical path to the data records according to the contents of a data item within each record that is the recorded key for that index.
The data item named in the RECORD KEY clause of the file control entry for a file is the prime record key for that file. For purposes of inserting, updating and deleting records in a file, each record is identified solely by the value of its prime record key. This value should, therefore, be unique and must not be changed when updating the record. The value must be unique unless the DUPLICATES phrase is specified in the RECORD KEY clause. When the DUPLICATES phrase is specified in the RECORD KEY clause, the value of the prime record key is not necessarily a unique identifier for a single record; therefore, in this case, the DELETE and REWRITE statements are disallowed in the random access mode and are sequential operations in the dynamic access mode.
Alternate record keys provide alternate means of retrieval for the records of a file. Such keys are named in the ALTERNATE RECORD KEY clause of the file control entry. The value of a particular alternate record key in each record must be unique unless the DUPLICATES phrase is specified in the ALTERNATE RECORD KEY clause.
For indexed organization, the order of sequential access is ascending based on the value of the current key of reference. If a collating sequence is specified for the file, it is used in determining the ascending sequence for keys. Any of the keys defined for the file may be established as the current key of reference during the processing of the file. The order of retrieval from a set of records that have duplicate key of reference values is the original order of arrival of those records into that set. The START statement may be used to establish a starting point within an indexed file for a series of subsequent sequential retrievals.
When an indexed file is accessed in random access mode, input-output statements are used to access the records in a programmer-specified order. The programmer specifies the desired record by placing the value of one of its record keys in a record key or an alternate record key data item.
In the dynamic access mode, the programmer may change at will from sequential access to random access using appropriate forms of input-output statements.
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, READ and START 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 the rules for 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 ANSI 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 2 Compile Command Option, which causes the compiler to treat the entire program as an ANSI COBOL 1974 program. That option and the language features it controls are discussed in detail in the Chapter Compiling, of theRM/COBOL User’s Guide.
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 relative file:
- I-O Status Value=00.The input-output statement is successfully executed and no further information is available concerning the operation.
- 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=10.A sequential READ statement is attempted and no next (or previous) logical record exists in the file because the end (or beginning) 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=14. A sequential READ statement is attempted for a relative file and the number of significant digits in the relative record number is larger than the size of the relative key data item specified for the file.
Invalid Key Condition with Unsuccessful Completion
- I-O Status Value=22.An attempt is made to write a record that would create a duplicate key in a relative file.
- I-O Status Value=23.Either an attempt is made to randomly access a record that does not exist in the file, or a START or random READ statement is attempted on an optional input file that is not present.
- I-O Status Value=24.Either an attempt is made to write beyond the externally defined boundaries of a relative file, or a sequential WRITE statement is attempted for a relative file and the number of significant digits in the relative record number is larger than the size of the relative key data item specified for the file.
- I-O Status Value=30.A permanent error exists and no further information is available concerning the input-output operation.
- 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 DELETE or REWRITE statement in the sequential access mode is attempted for a 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 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.
- 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 for one of the following reasons:
- I-O Status Value=47 [90, 91].A READ or START 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 I-O, output, or extend mode or on a sequential access file open in the I-O mode.
- I-O Status Value=49 [90, 91].A DELETE or 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- areas and control structures, or an OPEN statement is attempted for a file output 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=98.Defective record structure has been found in the file.
- I-O Status Value=99.A DELETE, READ, or REWRITE statement is attempted that refers to a record locked by another concurrent user. This I-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.
Invalid Key Condition
The invalid key condition can occur as a result of the execution of a DELETE, READ, REWRITE, START or WRITE statement. Details regarding the situations that cause an invalid key condition are presented in the sections of Chapter Procedure Division Statements, which explain the individual input-output statements. If an invalid key condition occurs, execution of the input-output statement that recognized the condition is unsuccessful and the file is not affected.
If the invalid key condition exists after the execution of the input-output operations called for by the input-output statement, the NOT INVALID KEY phrase, if specified, is ignored and the following actions occur in the order shown:
If the invalid key condition does not exist after the execution of the input-output operations called for by an input-output statement, the INVALID KEY phrase, if specified, is ignored and the following actions occur in the order shown:
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 appear in the discussion of the Format 1 READ statement.
When 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 Format 1 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.