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
Phil: I am using RPGLE and will give this a try today. Thanks for the reply!
Update: Worked perfectly!! Thanks again, Phil!
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.
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!