Hello,

We are having a problem on OS/400 V5R3, using COBOL on DB2 tables. The problem is that we are getting a status code 92 trying to do a random read. We checked all the obvious causes, but can't figure out what is wrong. The index is defined. The table is defined as INDEXED, access RANDOM, opened for INPUT. We are able to write to the table and read sequentially, but we can't do a random read. We’re using straight COBOL reads/writes, not using SQL.

Any help on this would be greatly appreciated. I am including the source code below - it's very short and simple. I can provide job logs, compile listings, etc for anyone interested. Thanks!




IDENTIFICATION DIVISION.

PROGRAM-ID. TESTINDX.

** AUTHOR NJB.
ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SOURCE-COMPUTER. IBM-AS400.
OBJECT-COMPUTER. IBM-AS400.

INPUT-OUTPUT SECTION.

FILE-CONTROL.

SELECT TESTTBL1-FILE ASSIGN TO DATABASE-TESTTBL1
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS TESTTBL1-FD-KEY
FILE STATUS IS WS-FILE-STATUS-SW.

SELECT PRINT-FILE ASSIGN TO PRINTER-QSYSPRT
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS WS-FILE-STATUS-SW.

/
DATA DIVISION.
FILE SECTION.

FD TESTTBL1-FILE.
01 TESTTBL1-FD-RECORD.
05 TESTTBL1-FD-KEY PIC X(04).
05 FILLER PIC X(20).

FD PRINT-FILE
RECORD CONTAINS 132 CHARACTERS
LABEL RECORDS ARE STANDARD.

01 PRINT-RECORD.
05 FILLER PIC X(132).

WORKING-STORAGE SECTION.

01 WS-TESTTBL1-DB-RECORD.
COPY DDS-ALL-FORMATS OF TESTTBL1.
/
************************************************** ************************
**
** MISCELLANEOUS WORK AREAS.
**
************************************************** ************************

01 WS-FILE-STATUS-SW PIC X(02).
88 GOODIO VALUE "00".
88 PERMANENT-I-O-ERROR VALUE "30".
88 RECORD-LOCKED-USER VALUE "90".
88 FILE-LOCKED-PROGRAM VALUE "91".
88 RECORD-LOCKED-PROGRAM VALUE "92".

01 WS-TESTTBL1-FOUND-SW PIC X(03).
88 TESTTBL1-FOUND VALUE "YES".

01 WS-END-OF-FILE-SW PIC X(03).
88 END-OF-FILE VALUE "YES".
01 WS-HOLD-KEY PIC 9(04).

01 WS-COUNT-TESTTBL1S PIC S9(6).
/
/
************************************************** ************************
**
** PROGRAM MESSAGE AREAS.
**
************************************************** ************************

01 WS-MESSAGE-A.
05 FILLER PIC X(39) VALUE
"ERRORS HAVE OCCURRED IN TESTINDX".
05 WS-ROUTINE PIC 9999.

01 WS-MESSAGE-B.
05 FILLER PIC X(12)
VALUE "FILE STATUS".
05 WS-FILE-STATUS PIC X(02).
05 FILLER PIC X(11)
VALUE "/I-OPER.".
05 WS-OPERATION PIC X(07).
05 FILLER PIC X(06) VALUE "/FILE".
05 WS-FILE-NAME PIC X(10).
05 FILLER PIC X(06) VALUE "/TEST".
05 WS-TESTTBL1 PIC 9999.

PROCEDURE DIVISION.

*DECLARATIVES.
************************************************** ************************

*END DECLARATIVES.
/

0000-MAINLINE SECTION.
0100-MAINLINE.
DISPLAY "PGM DISPLAY: STARTING PROGRAM TESTINDX".

OPEN OUTPUT PRINT-FILE.

OPEN INPUT TESTTBL1-FILE.
MOVE SPACES TO PRINT-RECORD.
STRING "FILE STATUS ON OPEN TESTTBL1-FILE "
DELIMITED BY SIZE
WS-FILE-STATUS-SW DELIMITED BY SIZE
INTO PRINT-RECORD
WRITE PRINT-RECORD.
MOVE SPACES TO PRINT-RECORD.

MOVE SPACES TO WS-FILE-STATUS-SW.

PERFORM 3000-READ-RANDOM.
CLOSE TESTTBL1-FILE
PRINT-FILE.
DISPLAY "PGM DISPLAY: ENDING PROGRAM TESTINDX".
STOP RUN.

3000-READ-RANDOM.

**** DOING RANDOM READ USING KEY VALUE OF "1234" ***********

MOVE SPACES TO WS-FILE-STATUS-SW.
INITIALIZE WS-TESTTBL1-DB-RECORD.

MOVE "1234" TO TESTTBL1-FD-KEY
READ TESTTBL1-FILE INTO WS-TESTTBL1-DB-RECORD
KEY IS TESTTBL1-FD-KEY
INVALID KEY PERFORM 9995-ABORT-PROGRAM-RUN.

MOVE SPACES TO PRINT-RECORD.
STRING "TESTKEY1 " DELIMITED BY SIZE
TESTTBL1-FD-KEY DELIMITED BY SIZE
" " DELIMITED BY SIZE
DESC1 DELIMITED BY SIZE
" TESTTBL1 READ RANDOM FILE STATUS = " DELIMITED BY SIZE
WS-FILE-STATUS-SW DELIMITED BY SIZE
INTO PRINT-RECORD
WRITE PRINT-RECORD.

9995-ABORT-PROGRAM-RUN.
************************************************** ************************
** ROUTINE PERFORMS AN EARLY EXIT FROM POST-PROCESSING AND DISPLAYS AN
** MESSAGE IDENTIFYING THE ROUTINE IN WHICH THE IRRECOVERABLE ERROR OCC
************************************************** ************************

MOVE WS-FILE-STATUS-SW TO WS-FILE-STATUS.
DISPLAY WS-MESSAGE-A.
DISPLAY WS-MESSAGE-B.
MOVE SPACES TO PRINT-RECORD.
STRING "PROGRAM TESTINDX ABORTED, FILE STATUS "
DELIMITED BY SIZE
WS-FILE-STATUS-SW DELIMITED BY SIZE
WS-MESSAGE-A DELIMITED BY SIZE
WS-MESSAGE-B DELIMITED BY SIZE
INTO PRINT-RECORD
WRITE PRINT-RECORD.

CLOSE TESTTBL1-FILE
PRINT-FILE.
STOP RUN.


9999-EXIT.
************************************************** ************************
** ROUTINE PERFORMS THE EXIT FROM THE PROGRAM'S POST-PROCESSING.
************************************************** ************************

EXIT.