RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

The /COPY and /INCLUDE directives Print E-mail
User Rating: / 0
Written by Chamara Withanachchi   

The /COPY and /INCLUDE directives allow the specification of files in either the QSYS file system or the IFS file system. In cases where the compiler cannot tell which file system the directive refers to, the search will begin in the file system of the file containing the /COPY directive.

When the compiler encounters a /COPY statement, the statement could refer to a file in the IFS or in the QSYS file system. If the name begins with a slash or is specified in single quotes, the name can only refer to a file in the IFS. A name in the IFS can be specified in double quotes as well. Where only part of the name is in double quotes, for example:


the name can only be a QSYS file system name.

If the name could be either in the QSYS file system or the IFS, the file system of the file containing the /COPY statement will be searched first. Note that upper-casing occurs for the QSYS file system (except with extended names specified with double quotes, such as ″A/B″) but not for the IFS. (The IFS is not case sensitive.)

Note: When searching for files in the IFS, if the file name does not contain a dot, the RPG compiler will look for files with the following suffixes (in this order): 1. no suffix (abc) 2. .rpgleinc (abc.rpgleinc) 3. .rpgle (abc.rpgle)

Search Path Within The IFS

You have two ways to indicate where /COPY and /INCLUDE files can be found in the IFS:

1. The INCDIR parameter, which lists the directories in the order you want them to be searched.
2. The RPGINCDIR environment variable, which has a colon-separated list of directores in the order you want them to be searched. To set the environment variable, use the ADDENVVAR or CHGENVVAR command.
For Example:


When searching for a relative file in the IFS (one whose path does not begin with /), the file will be searched for in the following places, in this order

1. The current directory.
2. The path specified by the INCDIR comand parameter.
3. The directories in the RPGINCDIR environment variable.
4. The source directory (if the source is an IFS file).

For example, if:

* The current directory is /home/auser.
* The INCDIR parameter is /driver/v5r2/inc:/driver/v5r1/inc.
* The RPGINCDIR environment variable is /home/auser/temp.
* The source is in directory /home/auser/src.

The directory search path takes precedence over the default-suffix order. If a file with no extension is searched for in several different directories, all suffixes will be tried in each directory before the next directory is tried.

<Previous   Next>