Overriding and Redirecting File Input and Output
in the program. For example, if the RPG device name is PRINTER, and the actual
file the program connects to is not a printer, the OS/400 system ignores the RPG
print spacing and skipping specifications.
There are other file redirections that the OS/400 system does not allow and that
cause the program to end. For example, if the RPG device name is WORKSTN
and the EXFMT operation is specified in the program, the program is stopped if the
actual file the program connects to is not a display or ICF file.
In ILE, overrides are scoped to the activation group level, job level, or call level.
Overrides that are scoped to the activation group level remain in effect until they
are deleted, replaced, or until the activation group in which they are specified ends.
Overrides that are scoped to the job level remain in effect until they are deleted,
replaced, or until the job in which they are specified ends. This is true regardless of
the activation group in which the overrides were specified. Overrides that are
scoped to the call level remain in effect until they are deleted, replaced, or until the
program or procedure in which they are specified ends.
The default scope for overrides is the activation group. For job-level scope, specify
OVRSCOPE(*JOB) on the override command. For call-level scope, specify
OVRSCOPE(*CALLLVL) on the override command.
See the
Data Management
manual for more detailed information on valid file redi-
rections and file overrides.
ILE Concepts
also contains information about overrides
and activation group vs. job level scope.
Example of Redirecting File Input and Output
The following example shows the use of a file override at compilation time.
Assume that you want to use an externally described file for a TAPE device which
does not have field-level description. You must:
1. Define a physical file named FMT1 with one record format that contains the
description of each field in the record format. The record format is defined on
the data description specifications (DDS). For a tape device, the externally
described file should contain only one record format.
2. Create the file named FMT1 with a Create Physical File CL command.
3. Specify the file name of QTAPE (which is the IBM-supplied device file name for
magnetic tape devices) in the RPG program. This identifies the file as externally
described (indicated by an E in position 22 of the file description specifications),
and specifies the device name SEQ in positions 36 through 42.
4. Use an override command–OVRDBF FILE(QTAPE) TOFILE(FMT1)–at compila-
tion time to override the QTAPE file name and use the FMT1 file name. This
command causes the compiler to copy in the external description of the FMT1
file, which describes the record format to the RPG compiler.
5. Create the RPG program using the CRTBNDRPG command or the CRTPGM
command.
6. Call the program at run time. The override to file FMT1 should not be in effect
while the program is running. If the override is in effect, use the CL command
DLTOVR (Delete Override) before calling the program.
Note: You may need to use the CL command OVRTAPF before you call the
program to provide information necessary for opening the tape file.
274 ILE RPG for AS/400 Programmer's Guide