COBOL/400 Language Help

ASSIGN Clause

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:

The general structure is:

->->----device-- -file-name--*--------------*-----><-
                           *--attribute--*

ASSIGN Clause

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:

The general structure is:

->->----device-- -file-name--*--------------*-----><-
                           *--attribute--*

device

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

Device specifies the type of device that the file will use. For TRANSACTION files device must be WORKSTATION.

-attribute

Attribute can be SI, which indicates that a separate indicator area is specified in the DDS for a FORMATFILE or WORKSTATION file.

-attribute

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

-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

-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.

RESERVE integer

The RESERVE clause reserves input-output areas. It is syntax-checked, but is treated as documentation.

ORGANIZATION

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.

INDEXED

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.

RELATIVE

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.

TRANSACTION

The ORGANIZATION IS TRANSACTION clause signifies interaction between a COBOL program and either a workstation user or another system.

ACCESS or MODE

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

SEQUENTIAL

SEQUENTIAL

RANDOM

RANDOM

DYNAMIC

DYNAMIC

DYNAMIC

RELATIVE

The RELATIVE KEY clause identifies a data-name that specifies the relative record number for a specific logical record within a relative file.

RELATIVE

The RELATIVE KEY clause specifies the relative record number for a specific record in a subfile.

data-name-3

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.

RECORD

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.

EXTERNALLY-DESCRIBED-KEY

Data-name-2


[ Top of Page | Previous Page | Next Page | Table of Contents ]