HP RPG/XL Programmer's Guide (30318-90001)

3- 1
Chapter 3 Using Disc Files in an RPG Program
RPG contains language elements that let you process several kinds of disc
files. You can use MPE files, Keyed Sequential Access Method (KSAM)
files and TurboIMAGE databases. The following list summarizes these
files and how you can use them in RPG programs:
File type: Ways you can access the file:
MPE Sequentially, randomly.
KSAM Sequentially, sequentially within key limits,
randomly and chronologically.
TurboIMAGE Sequentially, sequentially within key limits,
randomly.
A KSAM file consists of a data file and a key file. Data files contain
the actual data records and are maintained in chronological sequence
(records are placed in the file in the order that they are added). The
key file lets you access the data file records in key sequence. When you
create a KSAM file, you specify the fields that are the keys.
A TurboIMAGE database is a collection of files (data sets) whose data
field relationships are maintained automatically. You can easily query
data in TurboIMAGE databases and there are extensive file security
provisions that you can use.
This chapter discusses KSAM files and TurboIMAGE databases and how you
access and use them in RPG programs.
Indexed Disc Files (KSAM)
The following list summarizes the advantages and disadvantages of using
KSAM files. For in-depth information on KSAM files, see the
KSAM/3000
Reference Manual
.
Advantages:
* Can access records sequentially, chronologically, and by partial or
generic key value
* Efficient disc usage; the data portion of the file grows as records
are added
* No special utilities are required for loading and unloading data
* Multiple keys
* Key fields can be updated
* Deleted records are retrievable
* Duplicate keys
* KSAM files can be processed by FCOPY, SORT, EDITOR; you can also use
the operating system FILE command with them
* Fast updating when processing data sequentially
* RPG Specifications are easy to code
* Fixed or variable length data records
Disadvantages:
* No query facilities