Problem trying to open files

I'm using a Visual COBOL trial licence to migrate one program developed using a very old COBOL version to a newer one, and im facing a problem related to file handling.

The program needs to open a physical file twice at the same time, using INPUT and I-O modes. Below is one part of the code:

(...)
FILE SECTION.
FD ARQDK7 RECORD CONTAINS 1461 CHARACTERS
VALUE OF FILE-ID IS NOMSOR-DK7
DATA RECORD IS REG-DK7.
01 REG-DK7.
05 CHAVE-DK7 PIC X(16).
(...)

FD ARQDK7-CP RECORD CONTAINS 1461 CHARACTERS
VALUE OF FILE-ID IS NOMSOR-DK7-CP
DATA RECORD IS REG-DK7-CP.
01 REG-DK7-CP.
05 CHAVE-DK7-CP PIC X(16).
(...)

PROCEDURE DIVISION

MOVE "name_of_file" TO NOMSOR-DK7.
MOVE "name_of_file" TO NOMSOR-DK7-CP.

OPEN I-O ARQDK7.
OPEN INPUT ARQDK7-CP.
(...)

The I-O mode handles all the data process.
The INPUT mode is used only for verification while the program runs.

Thanks in advance.

  • Verified Answer

    I am not sure what the question is here.

    Are you asking if this is possible to define two files that point to the same physical filename?

    If so, then the answer is yes but you will have to specify a lock mode clause for the files or else the open i-o will lock the file for exclusive access and the open input will fail.

    You can do this by placing the LOCK MODE IS AUTOMATIC or LOCK MODE IS MANUAL clause in the select statement for both of the files.

    The default is that is you have records locked in one of the files then these locks will be detected on the read for the other file.

    You can change this behavior by placing the following file handler configuration option in your extfh.cfg file:

    RUNITLOCKDETECT=OFF

    Thanks.

  • Thanks Chris, i've tried to use UNLOCK ARQDK7, but nothing happened. Your suggestion was exacly what i needed !

  • Verified Answer

    Another option is to specify the sharing behaviour on the open statement itself.

    For example:

    OPEN I-O SHARING WITH ALL OTHER

    The SHARING phrase supports: ALL OTHER, NO OTHER, READ ONLY