What is the best way to test for data being retrieved so that if there isn't any data I can display a screen saying that there isn't any data instead of the response that looks like an error.This message has been edited. Last edited by: Jay Potter,
WebFocus 8.1.5 iSeries/Windows DB2/SQL/Access Dev Studio App Studio Maintain ReportCaster
April 09, 2012, 03:17 PM
Danny-SRL
Jay,
At the end of the report, after the END statement, you can add a test on the variable &RECORDS. Something like this:
...
END
-RUN
-IF &RECORDS GT 0 GOTO #DONE;
-HTMLFORM BEGIN
No records retrieved
-HTMLFORM END
-#DONE
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
April 09, 2012, 06:31 PM
Waz
I would suggest using &LINEs and not &RECORDS, as the &RECORDS indicates the number retrieved, and &LINES the number after sorting aggregation and WHERE TOTAL tests.
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
April 09, 2012, 10:14 PM
njsden
Unless your HOLDing your data before attempting to produce a report, also make sure EMPTYREPORT is set to OFF for your control logic on &LINES to kick in appropriately. EMPTYREPORT ON/ANSI does force the creation of report output so by the time you're evaluating &LINES it may be too late for your NO DATA message to be displayed (this is most likely to happen in PDF output).
You can display the error message with appropriate details for your selected input parameters as below:
.
.
.
-*After the end of report
-IF &LINES EQ 0 THEN GOTO NODATA;
-ELSE GOTO THEEND;
-NODATA
-SET &ERRMSG1 = 'There is no data retrieved for your given parameters.';
-SET &ERRMSG2 = 'Input 1:' | &ip1;
-SET &ERRMSG3 = 'Input 2:' | &ip2;
-GOTO ERRORMSG
-ERRORMSG
-HTMLFORM BEGIN
<HTML>
<BODY>
<P> &ERRMSG1 </P>
<P> &ERRMSG2 </P>
<P> &ERRMSG3 </P>
</BODY>
</HTML>
-HTMLFORM END
-THEEND
END
This message has been edited. Last edited by: SriAravind,
WebFocus Version 7.7.05 Windows, HTML/PDF/EXL2K/AHTML
April 10, 2012, 06:27 AM
Jay Potter
Thank you for all of the suggestions. I went with the &LINES suggestion. I then display a report with our company header and a line indicating that no information was pulled.
WebFocus 8.1.5 iSeries/Windows DB2/SQL/Access Dev Studio App Studio Maintain ReportCaster