The reports we create give the user the choice of PDF, EXL2K, CSV or HTML. EMPTYREPORT works well for PDF, EXL2K and HTML, however if you run in CSV you get an No HTML Output! page. I can get an message at the end of page that says there is no data but it still displays the number of records each table call produced (see sample below) 0 NUMBER OF RECORDS IN TABLE= 1 LINES 1 0 NUMBER OF RECORDS IN TABLE= 3 LINES 3 0 NUMBER OF RECORDS IN TABLE= 0 LINES 0 as well as a heading that says 'No HTML Output'.
Is there some way to do this. Below is a sample of the code I am running.
-SET &OUTFMT='COMT'; SET EMPTYREPORT=ON TABLE FILE CAR PRINT COUNTRY WHERE COUNTRY EQ 'NOTHING'; ON TABLE PCHOLD FORMAT &OUTFMT END -RUN
-IF &LINES EQ 0 GOTO EMPTYCSV; -EXIT -EMPTYCSV -HTMLFORM BEGIN
No data for this report.
-HTMLFORM ENDThis message has been edited. Last edited by: Laura1,
WebFOCUS 8105m as well as 7.6.11 Windows 10
March 31, 2010, 01:18 PM
fatboyjim
Hi,
You can hold the file first and check the number of records. And if there is at least one record then display it in the format of choice.
I had already seen Ginny's solution, however I was hoping not to have to another table call as we sometimes has several multi select variables that need to go in the where clause. But if this is the only way then I guess I will work with it.
WebFOCUS 8105m as well as 7.6.11 Windows 10
March 31, 2010, 04:24 PM
Dan Satchell
Will clearing the page before displaying your message solve the problem?
.
.
-IF (&LINES EQ 0) AND (&OUTFMT EQ 'COMT') GOTO EMPTYCSV ;
-EXIT
-EMPTYCSV
-HTMLFORM BEGIN
<SCRIPT Language="JavaScript">
document.body.innerHTML=""
</SCRIPT>
No data for this report.
-HTMLFORM END
WebFOCUS 7.7.05
March 31, 2010, 05:53 PM
Darin Lee
You could also just branch to a procedure that DOES run a valid report when &LINES EQ 0;
TABLE FILE CAR
PRINT COUNTRY NOPRINT
HEADING
"NO DATA FOR THIS REPORT"
WHERE READLIMIT EQ 1
ON TABLE SET ONLINE-FMT HTML
stylesheet stuff here....
END
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
April 01, 2010, 10:23 AM
Laura1
Thanks Dan, your suggestion works for me.
Thank you to everyone that responded
WebFOCUS 8105m as well as 7.6.11 Windows 10
April 12, 2010, 04:45 PM
Laura1
The code below only works some of the time.
quote:
-HTMLFORM BEGIN <script Language="JavaScript"> document.body.innerHTML=""
No data for this report.
-HTMLFORM END
Sometimes it produces an error Internet Explorer Cannot Open the Internet Site... Operation Aborted
From the research I have done, the line document.body.innerHTML="" appears to be causing this issue.
Does anyone know a different way that I can clear the page before displaying the line 'No data for this report.'
WebFOCUS 8105m as well as 7.6.11 Windows 10
April 12, 2010, 04:48 PM
Laura1
I have tried what Darin suggested, but it doesn't clear the page for some reason.
WebFOCUS 8105m as well as 7.6.11 Windows 10
April 12, 2010, 05:28 PM
Dan Satchell
Please make sure you have the closing script tag. Also, put a semi-colon at the end of the innerHTML statement.
The problem with my suggestion is that the first report needs to have some type of output. Either you HOLD is (which you don't want to do) or you display it in which case you get the No HTML Output error. And it would not clear the HTML page - it would just display the result of the first fex and then those of the second fex - which is what you are seeing.
Maybe you could try only creating a hold file if they choose COMT format. Or doing a sum the first time through (to only create a single line and shorten the HOLD process) check the &LINES for 0 records and then run the whole procedure again if &LINES NE 0. Just a couple of ideas--
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
April 12, 2010, 06:01 PM
njsden
Jimmy's suggestion:
quote:
You can hold the file first and check the number of records
Along with Darin's idea:
quote:
Maybe you could try only creating a hold file if they choose COMT format ... check the &LINES for 0 records and then run the whole procedure again if &LINES NE 0
Coupled with Tom's:
quote:
Do a hold with a recordlimit:
IF RECORDLIMIT EQ 10 -IF &LINES EQ 0 GOTO EMPTYCSV;
Should give you what you need without any significant penalty on performance, unless of course you're attempting to run a "huge" SQL aggregation query that takes a significant amount of time to be resolved even if the final answer set is "small" in which case you'd need to provide a special treatment for it.
All of their ideas combined should allow you to obtain the results you need.
0 NUMBER OF RECORDS IN TABLE= 1 LINES 1 0 NUMBER OF RECORDS IN TABLE= 3 LINES 3 0 NUMBER OF RECORDS IN TABLE= 0 LINES 0
Based on your sample output, it seems like you're attempting to retrieve records from different sources. If that assumption is correct, which result set is the one that is finally being "returned" as CSV?
Darin has hit the problem here, and that is that you are specifying PCHOLD which will return the results to your browser owing to the presence of the -RUN. The trouble is that you don't have any choice over the -RUN because you need to check the number of lines produced from your request.
What you need to do is to logically follow the flow through and identify where you need to intercept the processing to control the output to your users.
As Darin (and others) suggests, you need to HOLD the file when in COMT format so that you can identify when you have results to display. As you say, EMPTYREPORT is catering for the other types of output you need.
Also, as Nephtali implies and as you obviously have prior multiple TABLEs, you could identify when your output will contain no records at an earlier point in the process and redirect as necessary.
As a suggestion, try this and manipulate as required -
-SET &OUTFMT='COMT';
-SET &HOLDTYPE = IF &OUTFMT EQ 'COMT' THEN 'HOLD' ELSE 'PCHOLD';
SET EMPTYREPORT=ON
TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY EQ 'NOTHING';
ON TABLE &HOLDTYPE FORMAT &OUTFMT
END
-RUN
-IF &LINES EQ 0 GOTO EMPTYCSV;
PCHOLD FORMAT &OUTFMT
-EXIT
-EMPTYCSV
-HTMLFORM BEGIN
No data for this report.
-HTMLFORM END
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
April 14, 2010, 09:27 AM
Laura1
quote:
Please make sure you have the closing script tag. Also, put a semi-colon at the end of the innerHTML statement.
I know I didn't have the closing semi-colon and the closing script tag in on the thread here, but I did have them in on my actually code. Thanks for noticing just the same.
With regards to Tony's suggestion I am trying to create a standard piece of code that can be used in all our reports (approx. 50 reports). Using HOLD with 'COMT' means I would have to rerun the report if it has data. Some reports have as many as 15 to 20 goto labels in them which would make re-running the report alot more work as you would have to ensure that none of the labels are repeated and the dangers of causing a loop will be greatly increased. There doesn't seem to be an easy solution here.
WebFOCUS 8105m as well as 7.6.11 Windows 10
April 14, 2010, 11:42 AM
Darin Lee
Actually, if you look at Tony's code, he is not re-running it. The matrix still exists so you can output the result set again (if records exist) without having to re-run the entire code a second time.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
April 14, 2010, 11:55 AM
Tony A
quote:
means I would have to rerun the report if it has data
As Darin has pointed out, this is not a true statement, my suggestion just reuses the matrix.
You will not be able to use this method with TABLEF.
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
April 14, 2010, 12:55 PM
Laura1
Thank you, I did miss the line where Tony added the PCHOLD for when there was records. This seems to have solved the problem. Once again a big THANK YOU.