Highlighted
Absent Member.
Absent Member.
1611 views

Problem trying to open files

Jump to solution

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.

Tags (2)
0 Likes
2 Solutions

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Problem trying to open files

Jump to solution

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.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Problem trying to open files

Jump to solution

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

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Problem trying to open files

Jump to solution

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.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Problem trying to open files

Jump to solution

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

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Problem trying to open files

Jump to solution

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

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.