ILE COBOL Language Reference

+-------------------------------IBM Extension--------------------------------+

COPY Statement - Format 3 - Basic IFS

Copy Statement - Format 3 - Basic IFS
 
>>-COPY--+-text-name-+--+--------------------------+------------>
         '-literal-1-'  '-+-OF-+--+-library-name-+-'
                          '-IN-'  '-literal-2----'
 
>--+---------------+--+-----------------------+--.-------------><
   |          (1)  |  '-REPLACING--| phrase |-'
   '-SUPPRESS------'
 
 

Notes:

  1. IBM Extension

literal-1 and literal-2
literal-1 is the name of the stream file to copy. If library-name is omitted, the literal is used directly: as a file name, a relative path name, or an absolute path name (if the first character is '/'). For example:
COPY "MyInc"
COPY "x/MyInc"
COPY "/u/user1/MyInc" 
literal-2 is treated as the actual path, relative or absolute, from which the copy file text-name or literal-1 is located.
text-name
When text-name is a user-defined Cobol word and an environment variable of that name is defined, the value of the environment variable is used as the name of the file containing the copy text. If an environment variable of that name is not defined, the copy text is searched for according to the following names, in the order specified as follows:
1. text-name.cpy
2. text-name.CPY
3. text-name.cblle
4. text-name.CBLLE
5. text-name.cblleinc
6. text-name.CBLLEINC
7. text-name.cbl
8. text-name.CBL
9. text-name.cob
10. text-name.COB
11. text-name.MBR
12. text-name
library-name
When library-name is a user-defined Cobol word, it is treated as an environment variable. The value of the environment variable is used as the path from which the copy file, text-name or literal-1 is located. If the environment variable is not set, an error occurs. If both library-name and text-name are specified, the compiler forms the path name for the copy text by concatenating library-name and text-name with a path separator (/) inserted between the two values. For example, suppose you have the following setting for COPY MYCOPY OF MYLIB:
MYCOPY=mystuff/today.cpy
MYLIB=/u/user1

These settings result in:

/u/user1/mystuff/today.cpy

When library-name is an environment variable that identifies the path from which copy text is to be copied, use the ADDENVVAR command such as the following example to define library-name:

ADDENVVAR ENVVAR(COPYLIB) VALUE(/u/mystuff/copybooks)

The name of the environment variable must be uppercase. To specify more than one copy library, set the environment variable to multiple path names delimited by : (colon). When library-name is omitted and text-name is not an absolute path name, the copy text is searched for in this order:

  1. In the current directory
  2. In the paths specified on the INCDIR parameter
  3. In the paths specified in the SYSLIB environment variable

+----------------------------End of IBM Extension----------------------------+


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