ILE RPG Programmer's Guide


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: ADDENVVAR ENVVAR(RPGINCDIR) VALUE('/home/mydir:/project/prototypes')ADDENVVAR

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

Table 29. Search Order for /Copy Files
/Copy statement Files searched for
Assume the source file containing the
/COPY is /driver/src/main.rpg,
in the IFS

/COPY file.rpg
In IFS:

/home/auser/file.rpg
/driver/v5r2/inc/file.rpg
/driver/v5r1/inc/file.rpg
/home/auser/temp/file.rpg
/home/auser/src/file.rpg

In QSYS:

FILE(*LIBL/QRPGLESRC) MBR(FILE.RPG)
Assume the source file containing the
/COPY is MYLIB/QRPGLESRC
MYMBR, in the QSYS file system

/COPY file
In QSYS:

FILE(*LIBL/QRPGLESRC) MBR(FILE)

In IFS:

/home/auser/file
/home/auser/file.rpgleinc
/home/auser/file.rpgle

/driver/v5r2/inc/file
/driver/v5r2/inc/file.rpgleinc
/driver/v5r2/inc/file.rpgle

/driver/v5r1/inc/file
/driver/v5r1/inc/file.rpgleinc
/driver/v5r1/inc/file.rpgle

/home/auser/temp/file
/home/auser/temp/file.rpgleinc
/home/auser/temp/file.rpgle

/home/auser/src/file
/home/auser/src/file.rpgleinc
/home/auser/src/file.rpgle

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