Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spooled file staying in OPN status

Status
Not open for further replies.

mrderekg

IS-IT--Management
Feb 20, 2006
6
0
0
US
I'm trying to do some simple label printing using ILE RPG with an embedded SQL statement. The program compiles without errors and when I run it, the spooled file stays in OPN status unless I use a CLOSE statement in the file after the WRITE. If I use the CLOSE statement, the program runs fine, once and the next time I get an error that says 'I/O operation was applied to closed file'. If I then insert an OPEN statement, the next time I run the program I get the error 'OPEN was issued to opened file'.

I know I'm missing something simple but can't figure out what it is.

Many thanks,
Derek
 
Sorry, I should have thought to post the code the first time.

* SET CONNECTIONS TO EXTERNALLY DESCRIBED FILES
F*RPRT00 O E DISK
FRPRT01PR O E PRINTER
*
* Data Definitions
D LABELVARS DS
D Shipto1 5A
D WaveNo 2S 0
D BatchNo 7A
D CtrNo 11S 0
D WaveCntr 13A
*
***
*Open PRTF
C* OPEN RPRT01PR
*
C/EXEC SQL
C+ SELECT SUBSTR(SHIPTO,1,5), WAVE,
C+ BATCH, CONTAINER,
C+ DIGITS(WAVE)||DIGITS(CONTAINER)
C+ INTO :LABELVARS
C+ FROM WMSDTA/COC00
C+ WHERE CONTAINER = 1159998001
C/END-EXEC
C*Write record to printer
C WRITE MAIN
C*Close PRTF
C* CLOSE RPRT01PR
C RETURN

The source member is of type SQLRPGLE.
System is an i5 - AS/400 running V5R4

Thanks,
Derek
 
Indicate USROPN in the printer's F-Spec in the keywords. Without that, it doesn't know you want to control the open/close of the file.

I keep trying to do something about my procrastination but I keep putting it off until tomorrow.
 
That works perfectly! Thanks very much. I had a feeling it was something small and simple.

Thanks,
Derek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top