COBOL/400 Language Help
The ASSIGN clause associates a file with an external medium.
For sort or merge files (associated with an SD entry), no external medium
is used. The related ASSIGN clause is only validity checked and it is
not used for I-O.
Assignment-name-1 or literal-1 consists of three
parts:
- Device
- File name
- Attribute.
The general structure is:
->->----device-- -file-name--*--------------*-----><-
*--attribute--*
The ASSIGN clause associates the TRANSACTION file with a display file or
ICF file through the use of assignment-name-1 or
literal-1.
Assignment-name-1 or literal-1 consists of three
parts:
- Device
- File name
- Attribute.
The general structure is:
->->----device-- -file-name--*--------------*-----><-
*--attribute--*
Device specifies the type of device that the file will
use. The compiler checks whether the file is described and used in a
consistent manner.
Device specifies the type of device that the file will
use. For TRANSACTION files device must be WORKSTATION.
Attribute can be SI, which indicates that a separate indicator
area is specified in the DDS for a FORMATFILE or WORKSTATION file.
The attribute -SI specifies the file level option for a separate indicator
area. If you code -SI, then -file-name must refer to a file
that has the file level keyword INDARA specified in its DDS.
-file-name must be an unhyphenated 1- through 10-character
system name of the actual external file (physical or logical database, or
device). You must create the external file before compiling the
program, if the external file is used within the program by a COPY statement,
DDS (data description specifications) or DD format.
For database files, you cannot specify the member name in the
program. If you want to specify a member other than the first member,
you must use the Override with Database File (OVRDBF) CL command at execution
time to specify that member name.
This file name is the name of the AS/400 object that is displayed by the
Display Program References (DSPPGMREF) command. Since no external
medium is used for an SD file, the DSPPGMREF command does not list any files
defined for an SD file.
You can change the file name at execution time with the TOFILE parameter of
the OVRxxxF CL command. For consistent results, ensure that the device
type associated with the TOFILE parameter is the same as that specified for
assignment-name-1 or literal-1.
-file-name is a 1- through 10-character external name of the
display file or ICF file specified on the create device file commands CRTDSPF
or CRTICFF.
The RESERVE clause reserves input-output areas. It is
syntax-checked, but is treated as documentation.
The ORGANIZATION clause identifies the logical structure of the
file. The logical structure is established at the time the file is
created and cannot subsequently be changed.
If you omit the ORGANIZATION clause, the compiler assumes ORGANIZATION IS
SEQUENTIAL.
For database files, the ORGANIZATION clause indicates the current program
usage of the file in the program. Therefore, the same database file can
use SEQUENTIAL, INDEXED (assuming a keyed sequence access path exists), or
RELATIVE in the ORGANIZATION clause. This is true regardless of what
other programs that use this file specify.
When you specify the ORGANIZATION IS INDEXED clause, the position of each
logical record in the file is determined by the key sequence access path
created with the file and maintained by the system. The access path is
based on an embedded key within the file's records.
When you specify the ORGANIZATION IS RELATIVE clause, the position of each
logical record in the file is determined by its relative record number within
the arrival sequence access path.
The ORGANIZATION IS TRANSACTION clause signifies interaction between a
COBOL program and either a workstation user or another system.
The ACCESS MODE clause defines the manner in which the records of the file
are made available for processing. If you do not specify the ACCESS
MODE clause, sequential access is assumed.
- Sequential-Access Mode allows the reading and writing of records in a
serial manner; the order of reference is determined implicitly by the
position of a record in the file.
- In Format 1 (Sequential File Entries), records in the file are
accessed in the sequence established when the file is created or
extended. Format 1 supports only sequential access.
- Sequential-Access Mode allows the reading and writing of records in a
serial manner; the order of reference is determined implicitly by the
position of a record in the file.
- In Format 2 (Indexed File Entries), records in the files are
accessed in the sequence of ascending record key values according to the
collating sequence of the file.
- When you specify ACCESS IS SEQUENTIAL, the format name contained in the
format name field of the control area specifies which record was
accessed.
- When you specify ACCESS IS SEQUENTIAL for a TRANSACTION file, do not
specify the RELATIVE KEY data item.
- Random-Access Mode allows the reading and writing of records in a
programmer-specified manner; the control of successive references to the
file is expressed by specifically defined, user-supplied keys.
- In Format 2 (Indexed File Entries), the value placed in a
record key data item specifies the record to be accessed.
- Random-Access Mode allows the reading and writing of records in a
programmer-specified manner; the control of successive references to the
file is expressed by specifically defined, user-supplied keys.
- In Format 3 (Relative File Entries), the value placed in a
relative key data item specifies the record to be accessed.
- Dynamic-Access Mode allows a specific input-output to determine the access
mode. Therefore, records may be processed sequentially or
randomly.
- In Format 2 (Indexed File Entries), records in the file may be
accessed sequentially or randomly, depending on the form of the specific
input-output request.
- Dynamic-Access Mode allows a specific input-output request to determine
the access mode. Therefore, records may be processed sequentially
and/or randomly.
- In Format 3 (Relative File Entries), records in the file may be
accessed sequentially or randomly, depending on the form of the specific
input-output request.
- Dynamic-Access Mode allows a specific input-output request to determine
the access mode. Therefore, records may be processed sequentially or
randomly.
- Random accessing of a TRANSACTION file is only valid if you are performing
subfile processing. For subfile processing, you must specify ACCESS IS
DYNAMIC.
The RELATIVE KEY clause identifies a data-name that specifies the relative
record number for a specific logical record within a relative file.
The RELATIVE KEY clause specifies the relative record number for a specific
record in a subfile.
Data-name-3 is the RELATIVE KEY data item and you must define it as an
unsigned integer. It cannot be scaled. You must not define the
data item in a record description entry associated with the TRANSACTION
file.
The RECORD KEY clause specifies the data item within the record that is the
record key for an indexed file. Each record in the file must have a
unique record key value.
- You can use the reserved word EXTERNALLY-DESCRIBED-KEY to specify that the
keys for the file are those that are externally described in the data
description specifications (DDS).
- The keys are determined by the record formats that are copied by the COPY
statement (DDS, DD, DDSR, or DDR format), under the file description (FD) for
this file.
- The key can start at different offsets within the buffer for each
format. In this situation, you must be careful when changing from one
record format to another using a random READ or START statement. You
must place the key in the record format, at the correct offset in the format,
that will be used in the random access of the file. Unpredictable
results can occur if the key from the desired record is based on data that was
part of the last record read. This is because the movement of data to
the key field can involve overlapping records.
- The key within a format can be made up of multiple, noncontiguous (not
adjacent) fields. You should reference only those record formats copied
in within the FD for the file with the FORMAT phrase. If you reference
a format defined within the file, but that format has not been copied into the
program, the key is built using key fields defined for the first record format
copied. This can cause unpredictable results.
- If a portion of the key is declared in the logical file only as an element
of a concatenated item (rather than an independently-declared item), the
result of the CONCAT operation must not be a variable-length item.
- Data-name-2 represents the RECORD KEY data item.
Describe it as an alphanumeric item within a record description entry
associated with the file. The length of the record key is
restricted; the key length, in characters, cannot exceed 120.
- Data-name-2 may be a numeric item when the file is assigned to
a DATABASE device type. The numeric item can have a usage of DISPLAY,
COMP (COMP-3), COMP-4, PACKED-DECIMAL, or BINARY.
- Data-name-2 may be qualified, but it must not be
subscripted.
- The data description of data-name-2 and its relative location
within the record must be the same as those used when the file was defined in
DDS.
- The record description that defines data-name-2 will always be
used to access the record key field for the I-O operation.
[ Top of Page | Previous Page | Next Page | Table of Contents ]
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.