sachinbaby
Programmer
While attempting to delete an existing record from an indexed file, the cobol program reports an error "23".
Am able to read the record successfully (which I am attempting to delete), the key value displayed is also correctly;however if i attempt to delete the read record it returns error status "23".
The description of Error "23" is "An attempt was made to randomly access a record that does not exist in the file, or a START or random READ statement was attempted on an optional input file that was not present."
Note: I have noted that if I set the duplicate clause "no" in the describe/definition file (which is used to build the file) and reload the file, then am able to succesfully delete the record. However, I want the program to delete the record with value of 'duplicate' variable set to "yes" in the file definition file.
Portion of program attached for reference:
SELECT AAAFLE ASSIGN TO WS1-AAAFLE
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS AAA-KEY WITH DUPLICATES
LOCK MODE IS AUTOMATIC WITH LOCK ON RECORD
FILE STATUS IS E00-ERROR-STATUS.
Start Section
--------------
START AAAFLE KEY >= AAA-KEY
INVALID KEY
...
NOT INVALID KEY
...
END-START.
Read Section
-------------
READ AAAFLE NEXT WITH LOCK
AT END
MOVE "Y" TO WS-EOF
NOT AT END
...
END-READ.
Delete Section
----------------
DELETE AAAFLE RECORD
INVALID KEY DISPLAY "INVALID KEY"
END-DELETE.
Am able to read the record successfully (which I am attempting to delete), the key value displayed is also correctly;however if i attempt to delete the read record it returns error status "23".
The description of Error "23" is "An attempt was made to randomly access a record that does not exist in the file, or a START or random READ statement was attempted on an optional input file that was not present."
Note: I have noted that if I set the duplicate clause "no" in the describe/definition file (which is used to build the file) and reload the file, then am able to succesfully delete the record. However, I want the program to delete the record with value of 'duplicate' variable set to "yes" in the file definition file.
Portion of program attached for reference:
SELECT AAAFLE ASSIGN TO WS1-AAAFLE
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS AAA-KEY WITH DUPLICATES
LOCK MODE IS AUTOMATIC WITH LOCK ON RECORD
FILE STATUS IS E00-ERROR-STATUS.
Start Section
--------------
START AAAFLE KEY >= AAA-KEY
INVALID KEY
...
NOT INVALID KEY
...
END-START.
Read Section
-------------
READ AAAFLE NEXT WITH LOCK
AT END
MOVE "Y" TO WS-EOF
NOT AT END
...
END-READ.
Delete Section
----------------
DELETE AAAFLE RECORD
INVALID KEY DISPLAY "INVALID KEY"
END-DELETE.