how do I cancel printing of a user-open AS/400 print file?

5020 pts.
Tags:
AS/400
AS/400 printing
V6R1
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!

Answer Wiki

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

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

Discuss This Question: 4  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Koohiisan
    Phil: I am using RPGLE and will give this a try today. Thanks for the reply!
    5,020 pointsBadges:
    report
  • Koohiisan
    Update: Worked perfectly!! Thanks again, Phil!
    5,020 pointsBadges:
    report
  • hafwhit
    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 pointsBadges:
    report
  • Koohiisan
    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!
    5,020 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following