file user open exceptions for printer file
750 pts.
0
Q:
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: Aug 24 2009  8:12 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
24570 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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 Answered: Aug 25 2009  12:57 AM GMT by Philpl1jb   24570 pts.
Latest Contributors: Nutangujar   750 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Nutangujar   750 pts.  |   Aug 25 2009  1:40AM GMT

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…

 

TomLiotta   7785 pts.  |   Oct 11 2009  9:48AM GMT

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

 
0