Assignment name for user-defined words and literals

If USING is not specified, the user-defined word or literal that is specified for the assignment name is processed as described below.

Read syntax diagramSkip visual syntax diagram
Format: assignment-name

>>-+-----------+--+------------------+-------------------------->
   '-comment- -'  '-file-system-ID- -'   

>--+-system-file-name--+---------------+-+---------------------><
   |                   '-| alt-index |-' |   
   '-external-file-name------------------'   

alt-index

                          .----------------------------------.     
                          V                                  |     
|--(alt-index-file-name-1---+------------------------------+-+-)--|
                            '-,--+-----------------------+-'       
                                 '-alt-index-file-name-2-'         

If the user-defined word does not contain any hyphens, the entire string is treated as the external file-name. If the literal does not contain any hyphens, the entire string is treated as file name information. File name information can be a single system file-name, or a single system file-name followed by a list of alternate index file-names, or a concatenation of system file-names that are separated by colons. For each of these alternatives, each system file-name can be qualified by a path name. Otherwise, the user-defined word or literal is partitioned into up to three components separated by hyphens:

comment
Characters to the left of the file-system ID if specified, or characters to the left of the external file-name or system file-name if there is no valid file-system ID are interpreted as a comment.
file-system-ID
If the next-to-rightmost component meets all the following criteria, the first three characters of the string, folded to uppercase, are interpreted as the file-system ID:
  • The string consists of three or more characters.
  • The first (leftmost) three characters are alphanumeric (A-Z, a-z, or 0-9).
  • The first character is alphabetic (A-Z or a-z).

If the string does not meet all of these criteria, it is treated as part of the comment.

external-file-name or file name information
The rightmost component is the external file-name or one of the three forms of file name information.
Because the hyphen is used as the separator, an external file-name or system file-name that contains one or more hyphens cannot be specified directly with a user-defined word or a literal. To specify an external file-name or system file-name that contains one or more hyphens, use either of the following approaches:
  • Set the environment variable indicated by the external file-name to an appropriate value at run time.
  • Specify the USING data-name-9 form of the ASSIGN clause, and move an appropriate value to data-name-9 before opening the file.

If assignment-name-1 is specified as a user-defined word, external-file-name is interpreted at run time as the name of an environment variable set to a nonempty value or, if there is no such environment variable, directly as the system file-name.

If assignment-name-1 is specified as a literal, the rightmost component is always interpreted as file name information directly.

Examples:

Table 1. Assignment name for user-defined words
User-defined word Comment File-system ID External file-name
Read-Only-VSAM-Orders Read-Only SdU ORDERS
This-is-my-file This-is-my (Default) FILE
Comment-STL--file Comment-STL- (Default) FILE
Watch-for-this-file Watch-for THI (invalid) FILE
Table 2. Assignment name for literals
Literal Comment File-system ID System file-name
Read-Only-Vsam-Orders Read-Only SdU Orders
Eh?-What's this? Eh? (Default) What's this?
This-is-a-DB2-CICS.FILE This-is-a DB2 FILE (under schema CICS)
I-Like-STL!- I-Like STL (Null)
vsa-/.:/cics/sfs/svr/W123 (None) SFS W123 (on SFS server svr)
Specifying alternate indexes: The compiler normally assigns appropriate alternate index file-names; however, you must provide alternate index file-names for:
  • Indexed SFS files that have alternate indexes. Each index file-name is of this form:
    /.:/cics/sfs/sfsServer/base-file-name;index-file-name
  • Indexed SdU files that have alternate index files with names other than the COBOL compiler defaults. For example, a file that is created through a different language, such as PL/I.

Alternate index file-names, if specified, must be specified in the same order as the alternate record keys are specified in the source program. You can omit alternate index file-names, but any other alternate index file-names must correspond to the position in the file definition. The following example shows how to specify the first and third alternate index file-names:

base-file-name(first-index-file-name,,third-index-file-name)

In this example, the compiler assigns a default file-name for the second alternate index file.

Alternate index file-names are ignored for file systems other than SdU or SFS.