I've never used relative record number in COBOL. I'd like to know if
that's possible myself.
If it's not possible to use relative record number, you have some other
(1) Is there a non-key field in the file that reliably distinguishes
records with the same key field values? If so, pass the key fields plus
the non-key field to the second program. Have the second program start
on the key values, then read and compare the value of the non-key field
with the value passed in as a parameter.
(2) Create a new field in the file. The first program puts a value in
that field and rewrites it to "mark" it as the record to be processed.
Pass the key values to the second program, then have the second program
start and read until it sees the value in the new field. (You could also
adopt an unused field in the file for this purpose.)
(3) Use a counter. The first program sets the counter to zero and starts
on the file. With each read, the program increments the counter by one.
Pass the same start values and the counter value to the second program.
The second program starts in the same place and performs the same number
of reads (via counter value). Of course, for this to be reliable, the
file should not be manipulated (e.g., records added or deleted) while
the programs run.
Hope these give you some ideas.
[mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rich Loeber
Sent: Friday, November 07, 2008 12:52 PM
To: COBOL Programming on the iSeries/AS400
Subject: [COBOL400-L] Getting Relative Record Number After READ
I have a file that I am reading dynamically either forward, backwards
by first setting the START command. The file is indexed, but has the
capability of containing duplicate keys. After each read, I would
get at the exact relative record number of the record just read. I
to recall doing this some years ago, but the gray matter has lost it
altogether. I've been searching the IBM COBOL manuals to no avail.
need to know the exact record as I am calling another program that
needs to retrieve that exact same record, so passing just the record
will not work.
All suggestions appreciated.
Kisco Information Systems
As an Amazon Associate we earn from qualifying purchases.