Associating Files with Input/Output Devices - IBM - RPG

The key element for all I/O operations on the iSeries is the file. The system supports the following file types:

database files
allow storage of data permanently on system

device files
allow access to externally attached devices. Include display files, printer files, tape files, diskette files, and ICF files.

save files
used to store saved data on disk

DDM files
allow access to data files stored on remote systems.

Each I/O device has a corresponding file description of one of the above types which the program uses to access that device. The actual device association is made when the file is processed: the data is read from or written to the device when the file is used for processing.

RPG also allows access to files and devices not directly supported by the system, through the use of SPECIAL files. With a SPECIAL file, you must provide a program that handles the association of the name to the file, and the data management for the file. With other types of files, this is handled by RPG and the operating system.

To indicate to the operating system which file description(s) your program will use, you specify a file name in positions 7 through 16 of a file description specification for each file used. In positions 36 through 42 you specify an RPG device name. The device name defines which RPG operations can be used with the associated file. The device name can be one of: DISK, PRINTER, WORKSTN, SEQ, or SPECIAL.This shows a file description specification for a display (WORKSTN) file FILEX.

Identifying a Display File in an RPG Program

Identifying a Display File in an RPG Program

Note that it is the file name, not the device name (specified in positions 36 through 42) which points to the OS/400 file description that contains the specifications for the actual device.

The RPG device types correspond to the above file types as follows:

Correlation of RPG Device Types with iSeries File Types

Correlation of RPG Device Types with iSeries File Types

This illustrates the association of the RPG file name FILEX, as coded in Figure with a system file description for a display file.

Associating a file name with a display file description

Associating a file name with a display file description

At compilation time, certain RPG operations are valid only for a specific RPG device name. In this respect, the RPG operation is device dependent. One example of device dependency is that the EXFMT operation code is valid only for a WORKSTN device.

Other operation codes are device independent, meaning that they can be used with any device type. For example, WRITE is a device-independent operation.

The SEQ Device
The device SEQ is an independent device type.illustrates the association of the RPG file name FILEY with a system file description for a sequential device. When the program is run, the actual I/O device is specified in the description of FILEY. For example, the device might be PRINTER.

Associating a file name with a display file description

Associating a file name with a display file description

Although the file name and file type are coded in the RPG program, in many cases you can change the type of file or the device used in a program without changing the program. To find out how, see “Overriding and Redirecting File Input and Output” .


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM - RPG Topics