IBM AS/400 User Manual

Page of 489
 
 
Overriding and Redirecting File Input and Output
 
Chapter 15. General File Considerations
This chapter provides information on the following aspects of file processing on the
AS/400 using RPG:
¹
overriding and redirecting file input and output
¹
file locking by an RPG program
¹
record locking by an RPG program
¹
sharing an open data path
¹
AS/400 spooling functions
¹
using SRTSEQ/ALTSEQ in an RPG program versus a DDS file
Overriding and Redirecting File Input and Output
OS/400 commands can be used to override a parameter in the specified file
description or to redirect a file at compilation time or run time. File redirection
allows you to specify a file at run time to replace the file specified in the program
(at compilation time):
RPG program
Diskette
FILEY
Compile
Time
Override Command:
OVRDBF FILE (FILEY) TOFILE (FILEA)
Execution
Time
FILEA
File name = FILEY
Device = DISK
File type =
DEVICE
Device type =
DISKETTE
File type =
PHYSICAL
Figure  136.  Overriding File Input and Output Example
In the preceding example, the CL command OVRDBF (Override With Database
File) allows the program to run with an entirely different device file than was speci-
fied at compilation time.
To override a file at run time, you must make sure that record names in both files
are the same. The RPG program uses the record-format name on the input/output
operations, such as a READ operation where it specifies what record type is
expected.
Not all file redirections or overrides are valid. At run time, checking ensures that the
specifications within the RPG program are valid for the file being processed. The
OS/400 system allows some file redirections even if device specifics are contained
 Copyright IBM Corp. 1994, 1999 
 
273