Focal Point
[CLOSED] AHTMLTAB breaks when there is NO DATA

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2427094196

August 20, 2019, 12:47 PM
KLH
[CLOSED] AHTMLTAB breaks when there is NO DATA
Hi,
I have 2 reports that work great using AHTMLTAB in the HTMLFORM BEGIN and HTMLFORM END. However, when a Table File request does not bring back any data, the Active Report breaks. Is there a way to reset the system variable each time a request is made or capture the results of a table request Records or Lines in a variable? The &RECORD variable will contain the results of the first query and I can not use it for other queries to write out a NO DATA report. Any help would be greatly appreciated.

-*CHECK TO SEE IF I HAVE DATA FOR REPORT 1
TABLE FILE GGSALES
SUM DOLLARS UNITS
BY REGION
BY ST
BY CITY
ON TABLE HOLD
-SET &RECORDS = &RECORDS * 1 ;
-SET &LINES = &LINES * 1 ;
-IF &RECORDS = 0 THEN GOTO :NoData1 ELSE Big GrinataToShow;

-:NoData1
write a no data message

-Big GrinataToShow
TABLE FILE GGSALES
SUM DOLLARS UNITS
BY REGION
BY ST
BY CITY
HEADING "Regional Sales Summary"
ON TABLE HOLD AS REPORT1
FORMAT AHTMLTAB
ON TABLE SET STYLE *
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,
$
TYPE=REPORT,
OBJECT=STATUS-AREA,
PAGE-LOCATION=OFF,
$
END
-*CHECK TO SEE IF I HAVE DATA FOR REPORT 2
TABLE FILE GGSALES
SUM DOLLARS UNITS
BY CATEGORY
BY PRODUCT
ON TABLE HOLD
-IF &RECORDS = 0 THEN GOTO :NoData2 ELSE Big GrinataToShow2;

-:NoData2
write a no data message

-Big GrinataToShow2
TABLE FILE GGSALES
SUM DOLLARS UNITS
BY CATEGORY
BY PRODUCT
HEADING "Production Order Summary"
WHERE CATEGORY = 'KEN'
ON TABLE HOLD AS REPORT2
FORMAT AHTMLTAB
ON TABLE SET STYLE *
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,
$
TYPE=REPORT,
OBJECT=STATUS-AREA,
PAGE-LOCATION=OFF,
$
END -*
-HTMLFORM BEGIN


Displaying HTML Active Technologies Reports on an HTML Web Page


!IBI.OBJ.ACTIVEREPORTJS;






!IBI.FIL.REPORT1; !IBI.FIL.REPORT2;



-HTMLFORM END

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8202M, Windows, All Outputs
August 20, 2019, 02:25 PM
MartinY
ALWAYS use code tag when posting code sample
Last icon on the ribbon that looks like the below
</>


Pay attention : &RECORDS contain the number of record found/read where &LINES it's the number of records in the data set (returned) : in the HOLD file
You should better test &LINES

Also why doing
-SET &RECORDS = &RECORDS * 1 ;

&RECORDS and &LINES are already a number...

Except if you miss copied your code but you are missing key word END after your TABLE FILE … ON TABLE HOLD

To save BOTH "result" row number
-*CHECK TO SEE IF I HAVE DATA FOR REPORT 1
TABLE FILE GGSALES
SUM DOLLARS UNITS
-*WHERE CATEGORY = 'KEN';
ON TABLE HOLD
END
-RUN

-SET &RPT1 = &LINES;

-*CHECK TO SEE IF I HAVE DATA FOR REPORT 2
TABLE FILE GGSALES
SUM DOLLARS UNITS
-*WHERE CATEGORY = 'KEN';
ON TABLE HOLD
END
-RUN

-SET &RPT2 = &LINES;



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007