4,990 pts.
 how do I cancel printing of a user-open AS/400 print file?
I'm on V6R1 and I have a printed report that I need to suppress if it contains no data. Currently it prints out a heading section and then a notice that '0 records were modified.' Unfortunately, the program logic behind the report is not simple enough for me just to do a record count and see if it's 0 before I write anything to the printout. So, currently, it writes at the very least the headers before it determines if there is any data to be processed or not (it determines that one record at a time). When I get to the end of the program, I will know how many records were modified. Is there any way for me then to simply kill the printout even though I've started to write to the print file? I realize my question may leave a lot to be desired, but I was just curious if RPG has such a method. Thanks!

Software/Hardware used:
ASKED: July 29, 2009  7:32 PM
UPDATED: July 30, 2009  1:54 PM

Answer Wiki:
Assuming this is RPGLE If you want to delete the Spoolfile from insinde the RPG I think you will want to change the spool file to USROPN and Open it at the beginning of your process When you discover it should be deleted 1. Close the file 2. Issue a "DLTSPLF FILE(SpoolFileName) SPLNBR(*LAST) " From RPGLE that could be QCMDEXEC. Spool file is gone -- no printing. Alternative--------------- In CL just before the call to the rpg, ovrsplf to *Hold After the program if good data release spool file else dltsplf Your CL could pass a parameter to the program - &DelSpl RPG would modify it to notify you if it should print or be deleted Phil
Last Wiki Answer Submitted:  July 29, 2009  9:41 pm  by  philpl1jb   44,190 pts.
All Answer Wiki Contributors:  philpl1jb   44,190 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

Phil: I am using RPGLE and will give this a try today. Thanks for the reply!

 4,990 pts.

 

Update: Worked perfectly!! Thanks again, Phil!

 4,990 pts.

 

I would suggest not opening the print file until you get a detail record to print and then print the heading and the first detail record. If you don’t get a detail record to print then the print file would never be open and you would not need to delete it.

 1,145 pts.

 

Hafwhit: I agree with you, and I have done similar on some other similar reports. Actually, I perform an SQL count on the same criteria as what is going to be used to pull the detail records first. If it comes back with a zero count, I just skip the rest of the printing without opening/writing to the print file.

But, for this one, there’s no simple way to do the SQL count because each record has to be analyzed against another file for a few possible tests to determine whether to write it or not. I *could* just rewrite it to not print the headings until it sees that it needs at least one detail record…but this got me working for now. I may revisit it later and perform that change.

Thanks for the recommendation!

 4,990 pts.