15 pts.
 Logical File
Hi, I have written two online programs.  The first one uses PRDATA-FILE.  The second one uses a logical file based on PRDATA-FILE.  When the screen of the first online program is displayed, the screen of the second online program does not display records.  Is this because PRDATA-FILE is locked by the first online program? How do I make the second online program display records? Thanks in advance.

Software/Hardware used:
iSeries 820 / COBOL
ASKED: April 11, 2012  10:12 AM
UPDATED: April 26, 2012  7:43 PM

Answer Wiki:
It has been 23 years since I've even looked at a COBOL program. When you call the second 'online' program and the screen without records is shown, go to another session and type WRKOBJLCK PRDATA-FILE *FILE and see what kind of locks are on the file and where they are. In RPG, if you are not updating, the file would be defined as Input Only. Or, if the program does update, but not while retreiving records, you would read(n) or chain(n) (no lock) until right before actually wanting to write or update the file. Then read/chain without the (n) and write/update. When you write/update the file record is unlocked. Another option is in program 1, close the file before calling program 2. All of this said IF the issue is a file/record lock. It could just be a key out of whack or your code. Please send code....
Last Wiki Answer Submitted:  April 13, 2012  9:07 pm  by  NickHutcheson1   1,380 pts.
All Answer Wiki Contributors:  NickHutcheson1   1,380 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Not a COBOL guy but …

COBOL would not normally lock the file in a way that would prevent it’s use by other programs.

If it’s accessing the records for update it will lock the record(s). Your second program would not have a problem unless it’s attempting to access

    for update

a locked record. The number of records locked would depend on COMMIT level (if you are using Commitment Control).
Phil

 44,150 pts.

 

How do I make the second online program display records?

If we can’t see the relevant code for both programs, and the relevant definitions of the files, we can’t guess where something might be going wrong.

Show us what is running, please.

Tom

 108,055 pts.

 

What happens if you run the second program without running the first online program?

 5,670 pts.

 

Thanks for all your responses. The two programs are independent of each other. They both use PRDATA-FILE. When either is up on one session, the other program hangs in another session. Would like to know the syntax or technique to use for file sharing. Thanks in advance.

 15 pts.

 

Would like to know the syntax or technique to use for file sharing.

Generally, sharing is the default. Usually, the question would be about how not to share. We’re likely to ask you what you’re doing to block sharing.

When either is up on one session, the other program hangs in another session.

Any answers are likely to come out of information about that. What do you mean by “the other program hangs”? What exactly do you see? What is the exact behavior that is visible? Does the hanging program fail to start at all? Can both programs start, but one program begins to “hang” later? If you wait a couple minutes, does any error message appear? Does the hanging program become free if you end the first program?

Tom

 108,055 pts.

 

Are these programs designed to update existing data?
Please show us the file declaration section of your programs.
Thanks
Phil

 44,150 pts.