895 pts.
 file user open exceptions for printer file
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:
SQLrpgle
ASKED: August 24, 2009  8:12 PM
UPDATED: October 11, 2009  9:48 AM

Answer Wiki:
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. Phil ------------------- 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) Close(fileName) Endif Open (fileName)
Last Wiki Answer Submitted:  August 25, 2009  12:57 pm  by  philpl1jb   44,190 pts.
All Answer Wiki Contributors:  philpl1jb   44,190 pts. , Nutangujar   895 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

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 pts.

 

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

 108,260 pts.