This is all from the ILE RPG programmers redbook – there is more on the topic in the redbook. You can find at www.redbooks.ibm.com and search away.
0011.02 Ffilename IF E Disk RECNO(RRNF)
C RRNF Chain Filename
C If %Found
C Put your logic
Random input or update processing by relative record number applies to full procedural files only. The desired record is accessed by the CHAIN operation code. Relative record numbers identify the positions of the records relative to the
beginning of the file. For example, the relative record numbers of the first, fifth,
and seventh records are 1, 5, and 7, respectively.
For an externally described file, input or update processing by relative record
number is determined by a blank in position 34 of the file description
specifications and the use of the CHAIN operation code. Output processing by
relative record number is determined by a blank in position 34 and the use of the
RECNO keyword on the file description specification line for the file.
Use the RECNO keyword on a file description specifications to specify a numeric
field that contains the relative record number that specifies where a new record is
to be added to this file. The RECNO field must be defined as numeric with zero
decimal positions. The field length must be large enough to contain the largest
record number for the file. A RECNO field must be specified if new records are to
be placed in the file by using output specifications or a WRITE operation.
When you update or add a record to a file by relative record number, the record
must already have a place in the member. For an update, that place must be a
valid existing record; for a new record, that place must be a deleted record.
You can use the CL command INZPFM to initialize records for use by relative
record number. The current relative record number is placed in the RECNO field
for all retrieval operations or operations that reposition the file (for example,
SETLL, CHAIN, READ).
The above seems a little complex to me. The answer is very simple.
If you put a “K ” in front of “DISK” in the “F” specs, you are saying you will use a key.
Leave that column blank and you are saying you will process by relative record number.
(IIRC that column is “Access Method”)
Everything else remains the same.