[CLOSED] Displaying message when the report is empty for multiple Excel tabs
Hi,
My requirement is to produce multiple Excel tabs.If there are no records in one particular tab I should display "There are no records".
SET COMPOUND=OPEN
TABLE FILE CAR
PRINT SEATS
WHERE SEATS EQ '2';
ON TABLE PCHOLD FORMAT EXL2K
END
-IF &LINES EQ 0 THEN GOTO TABLE1 ELSE GOTO OTHERS;
-TABLE1
TABLE FILE CAR
PRINT SEATS NOPRINT
HEADING
"There are no records"
ON TABLE PCHOLD FORMAT EXL2K
END
-OTHERS
SET COMPOUND=CLOSE
TABLE FILE CAR
PRINT SEATS
WHERE SEATS EQ '6';
ON TABLE PCHOLD FORMAT EXL2K
END
-IF &LINES EQ 0 THEN GOTO TABLE2 ELSE GOTO OTHERS1;
-TABLE2
TABLE FILE CAR
PRINT SEATS NOPRINT
HEADING
"There are no records"
ON TABLE PCHOLD FORMAT EXL2K
END
-OTHERS1
-EXIT
Here is my code.If the first report(tab) has zero records, the message is being displayed correctly.But for the second tab,if there are zero records I don't see the second tab with the messagae.I am not sure why this is happening.where am I going wrong.Could some one help me.
ThanksThis message has been edited. Last edited by: Kerry,
WebFOCUS 7.6.7 windows Html,Pdf and Excel
November 09, 2011, 10:41 AM
Francis Mariani
Because it's a compound report, the second report closes the compound report, even though there's no data. Here is one solution - create a compound report with a dummy last report:
SET COMPOUND=OPEN
-RUN
TABLE FILE CAR
PRINT SEATS
WHERE SEATS EQ 2;
ON TABLE PCHOLD FORMAT EXL2K
END
-RUN
-IF &LINES EQ 0 THEN GOTO TABLE1 ELSE GOTO OTHERS;
-TABLE1
TABLE FILE CAR
PRINT SEATS NOPRINT
HEADING
"There are no records"
ON TABLE PCHOLD FORMAT EXL2K
END
-RUN
-OTHERS
TABLE FILE CAR
PRINT SEATS
WHERE SEATS EQ 6;
ON TABLE PCHOLD FORMAT EXL2K
END
-RUN
-IF &LINES EQ 0 THEN GOTO TABLE2 ELSE GOTO OTHERS1;
-TABLE2
TABLE FILE CAR
PRINT SEATS NOPRINT
HEADING
"There are no records"
ON TABLE PCHOLD FORMAT EXL2K
END
-RUN
-OTHERS1
SET COMPOUND=CLOSE
-RUN
TABLE FILE CAR
PRINT SEATS
WHERE SEATS EQ 999;
ON TABLE PCHOLD FORMAT EXL2K
END
-RUN
-EXIT
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 09, 2011, 02:24 PM
swetha
That was helpful.Is this the only way to do this.
WebFOCUS 7.6.7 windows Html,Pdf and Excel
November 09, 2011, 02:56 PM
Francis Mariani
I think this is the only way.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 09, 2011, 05:19 PM
Crymsyn
Another possible way is to add this to the top of your report
SET EMPTYREPORT = ANSI
Although it will not say "There are no records" it will just not have any data rows but keeps everything else (heading, footing, and column titles). If that would be okay for your requirement instead.
WF: 8201, OS: Windows, Output: HTML, PDF, Excel
November 10, 2011, 09:21 AM
AlexU
Add SET EMPTYREPORT = ON (or ANSI) and omit your branching statements.
TABLE FILE CAR PRINT SEATS WHERE SEATS EQ '2'; ON TABLE PCHOLD FORMAT EXL2K ON TABLE SET STYLE * TYPE=REPORT, FONT='Arial', SIZE=8, STYLE=NORMAL, TITLETEXT='Report 1',$ ENDSTYLE END
TABLE FILE CAR PRINT SEATS NOPRINT HEADING "There are no records" ON TABLE PCHOLD FORMAT EXL2K ON TABLE SET STYLE * TYPE=REPORT, FONT='Arial', SIZE=8, STYLE=NORMAL, TITLETEXT='Empty 1',$ ENDSTYLE END
TABLE FILE CAR PRINT SEATS WHERE SEATS EQ '6'; ON TABLE PCHOLD FORMAT EXL2K ON TABLE SET STYLE * TYPE=REPORT, FONT='Arial', SIZE=8, STYLE=NORMAL, TITLETEXT='Report 2',$ ENDSTYLE END
SET COMPOUND=CLOSE
TABLE FILE CAR PRINT SEATS NOPRINT HEADING "There are no records" ON TABLE PCHOLD FORMAT EXL2K ON TABLE SET STYLE * TYPE=REPORT, FONT='Arial', SIZE=8, STYLE=NORMAL, TITLETEXT='Empty 2',$ ENDSTYLE END