file user open exceptions for printer file

895 pts.
SQL error messages
i'm opening a program defined printer file in SQLRPGLE..

i get error file is already open....

if that is the case, then i'm trying to write in that file but now this gives me exception that attempting to write in closed file...


Please help

Software/Hardware used:

Answer Wiki

Thanks. We'll let you know when a new response is added.

1. You’ve got an F spec in the mainline – not subprocedure — something like ..
FprtFName O E Printer USROPN

2. You’ve got a command that you only process once?
Open(E) prtFName <– and you get error and it really the error file already open

3. You’ve got a write xxfmtName <– which is defined in the printer file prtFName and you get an error which is the file not open error???

Ohhhhhh, what a mystery!
If you’re calling the test program — rather than using sbmjob and it fails without getting the *INLR on
thennnnnnn the file may still be open the next tttttime you run. Sign-off and back-on and see if it runs the same.


Right – in initialization or when you need a different file (or seperate spool file)
This is “fail-safe” code. It’s the way to go.

IF %Open(fileName)
Open (fileName)

Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Nutangujar
    yeah...i did that..Thanks.... also to be on the safer side, in my RPG i check if the file is %Open in initialize routine. If yes then i Close the file first and then open...but that sounds weird to me.......I'm thinking of a scenario at client site...wat if such kinda mystery happens...i dun want my program to bomb...
    895 pointsBadges:
  • TomLiotta
    The RPG %open() BIF will report whether this program opened the file and has not yet closed it. That's not the same as reporting if the file is open or closed. There are ways for other programs to close files. If your program opens a file, %open() will return 'true' until your program closes the file -- even if the file was closed by a different program. Note that actions such as RCLRSC can close files. With recent Java Toolkit distributed transactions, the server program can close all files after transaction completion (potentially causing trigger programs problems if they expect secondary files to remain open; PTFs are available to control this). Make sure that you use features that are appropriate. RCLRSC buried somewhere in a job using ILE activation groups, for example, is not appropriate. Tom
    125,585 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: