Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Relative record files not being read correctly

 
SIddheswar Samant
Occasional Visitor

Relative record files not being read correctly

Hi,
I am using OpenVMS V7.3-2.

I have an Relative Record file with 42712 records(1 header record).

I tried to read the file randomly using HP-COBOL.
When I try to read with the record key value 96094, it retrieves the record with key value 41000.
Infact as per documentation, this should return an invalid key file status of 23.
Unfortunately it doesn't. I defined the key value as PIC 9(09) COMP.

Let me know if this is a bug with HP COBOL or is it something I am missing.

Thanks

Sid.


2 REPLIES
SIddheswar Samant
Occasional Visitor

Re: Relative record files not being read correctly

Here are some of the file attributes.

Record format: Fixed length 12 byte records

File organization: Relative, maximum record number: 2147483647

Let me know if you need more inputs.
Hein van den Heuvel
Honored Contributor

Re: Relative record files not being read correctly


This is OpenVMS.
There are no bugs in basic operations.


There is a problem in the program,
a lack of understanding, or both.

Check the START verb for the file.

Below a working example.

Hth,
Hein.

$ cre rel.fdl
file; org rel;
reco; form fix; size 12;
$ conver/trun/pad/stat/fdl=rel sys$library:vms$password_dictionary.data tmp.rel
... Total Valid Records: 42979
$
$ run RELATIVE
Key value:000000005
abandon
Key value:000000505
adjustment
Key value:000050505
Key : 000050505 is not valid in the file.
Key value:000040505
unnameable
Key value:

If you remove the "INVALID KEY" clause, then it will report:
File status 23 STS=000098994 STV=000000000
$ exit 0098994
%RMS-E-RNF, record not found


IDENTIFICATION DIVISION.
PROGRAM-ID. HEIN.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT THE-FILE
ASSIGN TO "TEST"
ACCESS MODE IS DYNAMIC RELATIVE KEY IS rel_key
ORGANIZATION IS RELATIVE
FILE STATUS IS FILE-STATUS.
DATA DIVISION.
FILE SECTION.
FD THE-FILE.
01 THE-RECORD.
03 SOME-DATA PIC X(12).
WORKING-STORAGE SECTION.
01 rel_key PIC 9(9) COMP.
01 FILE-STATUS PIC XX.
01 STS PIC 9(9).
01 STV PIC 9(9).
01 the-key PIC 9(9).

PROCEDURE DIVISION.

DECLARATIVES.
ERROR-HANDLER SECTION.
USE AFTER STANDARD EXCEPTION PROCEDURE ON THE-FILE.
HERE-WE-GO.
MOVE RMS-STS TO STS.
MOVE RMS-STV TO STV.
DISPLAY "File status ", FILE-STATUS, " STS=", STS, " STV=", STV.
END DECLARATIVES.

MAIN-CONTROL SECTION.
BEGIN-HERE.
OPEN I-O THE-FILE ALLOWING ALL.
THE-LOOP.
DISPLAY "Key value:" WITH NO ADVANCING.
ACCEPT THE-KEY AT END STOP RUN.
MOVE the-key TO rel_key.
START THE-FILE KEY IS EQUAL TO rel_key
INVALID KEY
DISPLAY "Key : ", the-key, " is not valid in the file."
GO TO the-loop.
READ THE-FILE RECORD
DISPLAY SOME-DATA.
GO TO THE-LOOP.