COBOL Subfiles
COBOL Subfiles
COBOL Subfiles
Description
The Format 5 READ statement is used only to read a format that is a subfile record.
You cannot use Format 5 for communications devices. If the subfile format of the
READ statement is used for a communication device, the READ operation fails.
The AT END phrase can only be specified when the NEXT MODIFIED phrase is
specified. The INVALID KEY phrase must not be used when the NEXT MODIFIED
phrase is specified.
->---*-------------------*--*--------*----------------------->
*-*------*-MODIFIED-* *-RECORD-*
*-NEXT-*
->---*-------------------*----------------------------------->
*-INTO identifier-1-*
->----*--------------------------------*--------------------->
*-FORMAT-*----*-*-identifier-2-*-*
*-IS-* *-literal-1----*
->----*----------------------------------*------------------->
*-TERMINAL-*----*-*-identifier-3-*-*
*-IS-* *-literal-2----*
->----*------------------------------------------*----------->
*-*-INDICATOR--*--*-----*--identifier-4----*
*-INDICATORS-* *-IS--*
*-INDIC------* *-ARE-*
->---*--------------------------------------------*---------->
*-INVALID---*-----*---imperative-statement-1-*
*-KEY-*
->---*------------------------------------------------*------>
*-NOT INVALID---*-----*---imperative-statement-2-*
*-KEY-*
->----*-----------------------------------*------------------>
*-*----*-END imperative-statement-3-*
*-AT-*
->----*---------------------------------------*-------------->
*-NOT-*----*-END imperative-statement-4-*
*-AT-*
->---*----------*--------------------------------------------><-
*-END-READ-*
file-name
File-name must be defined in a Data Division FD entry, and must not name a sort or
merge file. If more than one record-description entry is associated with file-name,
these records automatically share the same storage area. That is, they are implicitly
redefined.
INTO
When you specify the INTO phrase, the current record moves from the input area to
the identifier area according to the rules for the MOVE statement without the
CORRESPONDING phrase. Any subscripting, indexing, or reference modification
associated with the identifier is evaluated after the record has been read and
immediately before it is transferred to the identifier. (Click here for information about
reference modification.)
Only one record description is subordinate to the file description entry, or,
All record-names associated with file-name, and the data item referenced by
identifier-1, describe a group item, a numeric-edited item, or an elementary
alphanumeric item.
You cannot specify the INTO phrase when the file contains records of various sizes,
as indicated by their record descriptions. The storage area associated with the
identifier and the record area associated with the file-name cannot be the same
storage area.
identifier-1
Identifier-1 refers to a data item described as a group item, a numeric-edited item, or
an elementary alphanumeric item.
NO LOCK
The NO LOCK phrase prevents the READ operation from obtaining record locks on
files that you open in I-O (update) mode. A READ statement with this phrase also
releases records that have been locked by a previous READ operation.
If you use this phrase for a file that is not open in I-O mode, you receive an error
message.
FORMAT
The value specified in the FORMAT phrase contains the name of the record format to
use for this I-O operation. The system uses this to specify or select which record
format to operate on.
identifier-2 or literal-1
Literal-1 or identifier-2 specifies the name of the record format to be read. If you
specify literal-1 it must be nonnumeric, uppercase, and 10 characters or less in
length. If you specify identifier-2, it must refer to an alphanumeric data item, 10
characters or less in length. If identifier-2 contains blanks, the READ statement runs
as if the FORMAT phrase were omitted.
END imperative-statement-1 or -2
The AT END phrase serves to explicitly delimit the scope of the READ statement.
The imperative statement is executed when the AT END condition is detected. Any
EXCEPTION/ERROR procedure for the file is not run. If the AT END phrase is not
specified, any EXCEPTION/ERROR procedure for the file is run. Return from that
procedure is to the next executable statement following the end of the READ
statement.
NEXT
For a dynamic access READ NEXT statement, the file position indicator is positioned
to point to the next record in the file. That record is then made available.
This applies to sequential retrieval from disk and database files, with either relative or
indexed organization.
FIRST
For a dynamic access READ FIRST statement, the file position indicator is positioned
to point to the first record in the file. That record is then made available.
This applies to sequential retrieval from a database file with indexed organization.
LAST
For a dynamic access READ LAST statement, the file position indicator is positioned
to point to the last record in the file. That record is then made available.
This applies to sequential retrieval from a database file with indexed organization.
This applies to sequential retrieval from a database file with indexed organization.
KEY
The KEY IS phrase may be specified only for indexed files.
The KEY IS phrase is syntax checked only and has no effect on the operation of the
READ statement.
data-name-1
Data-name-1 must identify a record key associated with file-name. Data--name-1
may be qualified but it may not be subscripted.
Click here for further information about the invalid key condition.
TERMINAL
The TERMINAL phrase specifies the program device from which the data record is
made available. The program device must have been acquired before the READ
operation. For a single device file, the TERMINAL phrase can be omitted. The
program device is assumed to be that single device. If the TERMINAL phrase is
omitted for a READ of a TRANSACTION file that has acquired multiple program
devices, the default program device is used.
identifier-3 or literal-2
Literal-2 or identifier-3 specifies the program device name. If you specify literal-2, it
must be nonnumeric and 10 characters or less in length. If you specify identifier-3, it
must refer to an alphanumeric data item 10 characters or less in length. If identifier-3
contains blanks, the READ statement executes as if the TERMINAL phrase had been
omitted.
INDICATOR
The INDICATOR phrase specifies which indicators are to be read. When a data
record is read, indicators can be read with it. The indicators can be used to pass
information about the data record and how it was entered into the program.
INDICATOR, INDICATORS, and INDIC are equivalent.
identifier-4
Identifier-4 must be either an elementary Boolean data item specified without the
OCCURS clause, or a group item that has elementary Boolean data items
subordinate to it.
NO DATA imperative-statement-1
When you specify the NO DATA phrase, the READ statement will determine whether
data is immediately available. If data is available, the data is returned in the record
area. If no data is immediately available, imperative-statement-1 is executed. The NO
DATA phrase prevents the READ statement from waiting for data to become
available.
SUBFILE
When you specify the SUBFILE phrase, it indicates that all formats referenced by the
statement are subfiles. When you do not specify SUBFILE in a TRANSACTION I/O
statement, it indicates that none of the formats referenced by the statement are
subfiles.
When SUBFILE is specified, a RELATIVE KEY data item must be defined for the file.
Its value is referenced, and sometimes changed, by the I/O operation.
When SUBFILE is not specified, the RELATIVE KEY data item associated with the
file, if specified, is not referenced or changed by the I/O operation.
You can specify the SUBFILE phrase only for display files.
When you specify the NEXT MODIFIED phrase, the record made available is the first
record in the subfile that has been modified.
The value of the RELATIVE KEY data item is updated to reflect the relative record
number of the record made available to the program.
If you specify NEXT MODIFIED and there is no user-modified record in the subfile
with a relative record number greater than the relative record number contained in
the RELATIVE KEY data item, the AT END condition exists, the file status is set to 12,
and the value of the RELATIVE KEY data item is set to the key of the last record in
the subfile. Imperative-statement-2, or any applicable USE AFTER
ERROR/EXCEPTION procedure, if any, is then executed.
If you do not specify the NEXT MODIFIED phrase, the data record made available is
the record in the subfile with a relative record number that corresponds to the value
of the RELATIVE KEY data item; and if the RELATIVE KEY data item contains a
value other than the relative record number of a record in the subfile, the INVALID
KEY condition exists and the execution of the READ statement is unsuccessful.
Random Access of Subfile Records: The NEXT MODIFIED phrase must not be used
to randomly access records in a subfile. The INVALID KEY phrase can only be used
for random access of subfile records.
If you specify the FORMAT phrase, literal-1 or the contents of identifier-2 must
specify a format which is active for the appropriate program device. The READ
statement reads a data record of the specified format.
When a format-name is not specified, the format used is the last record format written
to the display device that contains input fields, input/output fields, or hidden fields. If
no such format exists for the display file, the format used is the record format of the
last WRITE operation to the display device.
To ensure correct results, always specify the FORMAT phrase for multiple format
files.
TERMINAL
The TERMINAL phrase specifies the program device from which the data record is
made available. The program device must have been acquired before the READ
operation. For a single device file, the TERMINAL phrase can be omitted. The
program device is assumed to be that single device. If the TERMINAL phrase is
omitted for a READ of a TRANSACTION file that has acquired multiple program
devices, the default program device is used.
If the TERMINAL phrase is omitted for a file that has multiple devices acquired for it,
a record is read from the subfile associated with the default program device.
The INVALID KEY phrase should be specified if the NEXT MODIFIED phrase is not
specified and there is no applicable USE procedure specified for the file name.
If the RELATIVE KEY data item contains a value that does not correspond to a
relative record number for the subfile at the time of the execution of the READ
statement, the INVALID KEY condition exists and the execution of the READ
statement is unsuccessful.
Click here for further information about the invalid key condition.
END imperative-statement-3
The AT END phrase serves to explicitly delimit the scope of the READ statement.
Specify the AT END phrase when you use the NEXT MODIFIED phrase and no
applicable USE procedure is specified for the file name. If the AT END phrase and a
USE procedure are both specified for a file, and the AT END condition arises, control
transfers to the AT END imperative statement and the USE procedure is not
executed.
If you specify NEXT MODIFIED and there is no user-modified record in the subfile,
the AT END condition exists, and the READ operation is unsuccessful.
RELEASE Statement
Description
The RELEASE statement transfers records from an input/output area to the
initial phase of a sorting operation. You can only use the RELEASE statement
within the range of an input procedure associated with a SORT statement.
->->---RELEASE record-name-1---*-------------------*----------><-
*-FROM identifier-1-*
The move into the identifier takes place according to the rules for the MOVE
statement for a group move without the CORRESPONDING phrase.
->---*-------------------------------------------*----------->
*-*----*-EXCEPTION imperative-statement-1---*
*-ON-*
->---*-----------------------------------------------*------->
*-NOT-*----*-EXCEPTION imperative-statement-2---*
*-ON-*
->---*------------*------------------------------------------><-
*-END-ACCEPT-*
mnemonic-name
EXCEPTION imperative-statement-1
The move into identifier-1 takes place according to the rules for the MOVE
statement for a group move without the CORRESPONDING phrase.
There is only one local data area for each job, and all devices in a job access
the same local data area.
->---*----------------------*--------------------------------><-
*-FOR-*-identifier-2-*-*
*-literal------*
identifier-1
mnemonic-name
FOR
When you specify the FOR phrase, it is syntax checked during compilation but
treated as a comment during execution.
identifier-2 or literal
The value of literal or identifier-2 indicates the program device associated with the
local data area.
identifier
mnemonic-name
Mnemonic-name must be associated in the SPECIAL-NAMES paragraph with an
input/output device: a workstation (REQUESTOR), or a system operator's
message queue (CONSOLE or SYSTEM-CONSOLE).
environment-name
DATE
911225
The conceptual data items DATE, DAY, and TIME implicitly have USAGE
DISPLAY. Since they are conceptual items, they cannot be described in the
COBOL program.
DAY
The conceptual data items DATE, DAY, and TIME implicitly have
USAGE DISPLAY. Since they are conceptual items, they cannot be
described in the COBOL program.
TIME
14410000
COMMIT Statement
Description
The COMMIT statement provides a way of synchronizing changes to data
base records while preventing other jobs from modifying those records until
the COMMIT is performed.
When the COMMIT statement is executed, all changes made to files under
commitment control since the previous commitment boundary are made
permanent. A commitment boundary is established by the successful
execution of a ROLLBACK or COMMIT statement. If no COMMIT or
ROLLBACK has been issued in the current job, a commitment boundary is
established by the first OPEN of any file under commitment control in the job.
Changes are made to all files under commitment control in the job, not just to
files under commitment control in the COBOL program that issues the
COMMIT statement.
When a COMMIT is executed, all record locks held by the job since the last
commitment boundary for files under commitment control are released and the
records become available to other jobs.