Search Path Within The IFS
Search Path Within The IFS
You have two ways to indicate where /COPY and /INCLUDE files can be found in the IFS:
-
The INCDIR parameter, which lists the directories in the order you want them to be searched.
For example:
CRTRPGMOD ... INCDIR('/home/mydir' '/project/prototypes') -
The RPGINCDIR environment variable, which has a colon-separated list of directories 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')
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
- The current directory.
- The directories specified by the INCDIR command parameter.
- The directories in the RPGINCDIR environment variable.
- The source directory (if the source is an IFS file).
For example, if:
- The current directory is /home/auser.
- The INCDIR parameter is /driver/r1.2/inc:/driver/r1.1/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.
Table 1. 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/r1.2/inc/file.rpg /driver/r1.1/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/r1.2/inc/file /driver/r1.2/inc/file.rpgleinc /driver/r1.2/inc/file.rpgle /driver/r1.1/inc/file /driver/r1.1/inc/file.rpgleinc /driver/r1.1/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 |