God_of_Thunder
God_of_Thunder

Reputation: 763

Under what circumstances will OVRDBF cause error message CPF5149 to be prompted?

I am currently working on four of CL and RLG programs. The call stack is as follows: A->B->C->D where A is the top caller CL program and D is the bottom callee RPG program. Program A has an OVRDBF statement with SHARE(*YES) option on a file, which is used as output in program D. Now I am facing a problem, which is that whenever D tries to write a record into this file error message CPF5149 is thrown telling me that the I/O operation is not valid. If I comment this OVRDBF statement in program A then D can write the record into the file without any problem. So why exactly does this OVRDBF cause trouble with I/O in a RPG program? How to solve it? Removing it might not be an option.

Upvotes: 0

Views: 3713

Answers (1)

James Allman
James Allman

Reputation: 41198

The SHARE(*YES) option to OVRDBF keeps the data path open. If the first program in your call stack that opens the file opens it as read-only then it will stay that way for all other programs.

Generally SHARE(*YES) is only used when you want to use the OPNQRYF command to filter records before passing them into another program.


UPDATE:

The open attributes of programs B, C and D (whichever is first to open the file) in your example will control the open status.

If you are using OPNQRYF specify the OPTION(*ALL) parameter to force it to open the data path with full read/write/update/delete attributes.


IBM i Information Center: Sharing an Open Data Path

Upvotes: 3

Related Questions