Focal Point
[SOLVED] Using -IF...THEN GOTO...ELSE GOTO on Compound reports

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

October 18, 2018, 11:48 AM
intsoccersuperstar
[SOLVED] Using -IF...THEN GOTO...ELSE GOTO on Compound reports
Hello, I am a WebFOCUS newbie trying to get up to speed quickly. Thanks in advance for any help or assistance anyone can provide.

I am writing a compound report (one that outputs to multiple excel tabs) that also utilizes if/then/else statements to control the content of the tabs. My report looks like this:

-DEFAULT &Var1 = 0;
-DEFAULT &Var2 = 0;
-SET &Var1=IF &Var1 EQ 0 THEN 'FOC_NONE' ELSE &Var1;
-SET &Var2=IF &Var2 EQ 0 THEN 'FOC_NONE' ELSE &Var2;

Report Contents

;
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K OPEN
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
TITLETEXT='Excel Tab 1',
GRID=OFF,
FONT='TIMES NEW ROMAN',
SIZE=10,
$
TYPE=TITLE,
COLOR='WHITE',
BACKCOLOR=RGB(96 131 159),
STYLE=BOLD,
$
TYPE=REPORT,
COLUMN=N8,
SQUEEZE=OFF,
$
ENDSTYLE

-IF &LINES EQ 0 THEN GOTO BLANKER ELSE GOTO JUMPBLANKER;

-BLANKER
DEFINE FILE output_from_report1
NOREC/A60='No records found that match your parameters.';
END
TABLE FILE output_from_report1
PRINT NOREC AS ''
BY column1 NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K OPEN
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
ORIENTATION=PORTRAIT,
TITLETEXT='Excel Tab 1',
$
TYPE=REPORT,
SQUEEZE=OFF,
STYLE=BOLD,
WRAP=0,

$
ENDSTYLE

-JUMPBLANKER
-*=========================Next tab=======================================
-RUN
Report Contents

;
ON TABLE SET HTMLENCODE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K CLOSE
ON TABLE SET STYLE *
TITLETEXT='Excel Tab 2',

$
UNITS=IN,
PAGESIZE='Letter',
LEFTMARGIN=0.500000,
RIGHTMARGIN=0.500000,
TOPMARGIN=0.500000,
BOTTOMMARGIN=0.500000,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
GRID=OFF,
FONT='GARAMOND',
SIZE=10,
RIGHTGAP=0.125000,
TOPGAP=0.013889,
BOTTOMGAP=0.027778,
JUSTIFY=CENTER,
$
ENDSTYLE


-IF &LINES EQ 0 THEN GOTO BLANKER2 ELSE GOTO JUMPBLANKER2;

-BLANKER2
DEFINE FILE output_from_report2
NOREC1/A60='No records found that match your parameters 2.';
END
TABLE FILE output_from_report2
PRINT NOREC1 AS ''
BY column1 NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE SET HTMLENCODE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K CLOSE
ON TABLE SET STYLE *
TITLETEXT='Excel Tab 2',
$
TYPE=REPORT,
GRID=OFF,
STYLE=BOLD,
WRAP=0,

$
ENDSTYLE
END
-JUMPBLANKER2
END

If the second report has no lines, I cannot get Excel Tab 2 to generate with my message. The first tab always generates correctly no matter what, and both tabs generate correctly if they both have lines.

I think the problem is the ON TABLE PCHOLD FORMAT EXL2K CLOSE statement after the second report is finished (before we get to BLANKER2). If I delete CLOSE, then the reports generate correctly when second report has no lines. However, without CLOSE there, when the second report DOES have lines, the entire compound report just gives me a "Your request did not return any output to display" message.

Any help would be greatly appreciated, thanks!

This message has been edited. Last edited by: intsoccersuperstar,


intsoccersuperstar
WebFOCUS 8105m
Windows, Excel
October 18, 2018, 12:16 PM
MartinY
Two things that I can see

1- You need the key word END after each ENDSTYLE. The END tells Focus that the TABLE FILE ... is completed. Put it at each place to have a better reading.
2- You already have closed your Excel file if no data is found for tab 2 before going to BLANKER2

To solve situation -2- what I would do is to first extract your report data and hold it. Then if you have data then generate the Excel tab with the data otherwise go to the "empty" tab

something such as this

TABLE FILE FILE1
....
ON TABLE HOLD AS DATATAB1
END
-RUN

-IF &LINES GT 0 GOTO TAB1 ELSE GOTO EMPTYTAB1;

-TAB1
TABLE FILE DATATAB1
...
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K OPEN
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
 UNITS=IN,
 SQUEEZE=ON,
 ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
	TITLETEXT='Excel Tab 1',
 GRID=OFF,
 FONT='TIMES NEW ROMAN',
 SIZE=10,
$
TYPE=TITLE,
 COLOR='WHITE',
 BACKCOLOR=RGB(96 131 159),
 STYLE=BOLD,
$
TYPE=REPORT,
 COLUMN=N8,
 SQUEEZE=OFF,
$
ENDSTYLE
END
-RUN
-GOTO EXTTAB2

-EMPTYTAB1
DEFINE FILE output_from_report1
NOREC/A60='No records found that match your parameters.';
END
TABLE FILE output_from_report1
PRINT NOREC AS ''
BY column1 NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K OPEN
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
	UNITS=IN,
	ORIENTATION=PORTRAIT,
	TITLETEXT='Excel Tab 1',
$
TYPE=REPORT,
SQUEEZE=OFF,
STYLE=BOLD,
WRAP=0,

$
ENDSTYLE
END
-RUN
-GOTO EXTTAB2

-EXTTAB2
TABLE FILE FILE2
...
ON TABLE HOLD AS DATATAB2
END
-RUN

-IF &LINES GT 0 GOTO TAB2 ELSE GOTO EMPTYTAB2;

-TAB2
TABLE FILE DATATAB2
...
ON TABLE SET HTMLENCODE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K CLOSE
ON TABLE SET STYLE *
TITLETEXT='Excel Tab 2',

$
 UNITS=IN,
 PAGESIZE='Letter',
 LEFTMARGIN=0.500000,
 RIGHTMARGIN=0.500000,
 TOPMARGIN=0.500000,
 BOTTOMMARGIN=0.500000,
 SQUEEZE=ON,
 ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
 GRID=OFF,
 FONT='GARAMOND',
 SIZE=10,
 RIGHTGAP=0.125000,
 TOPGAP=0.013889,
 BOTTOMGAP=0.027778,
 JUSTIFY=CENTER,
$
ENDSTYLE
END
-RUN
-EXIT

-EMPTYTAB2
DEFINE FILE output_from_report2
NOREC1/A60='No records found that match your parameters 2.';
END
TABLE FILE output_from_report2
PRINT NOREC1 AS ''
BY column1 NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE SET HTMLENCODE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K CLOSE
ON TABLE SET STYLE *
	TITLETEXT='Excel Tab 2',
$
TYPE=REPORT,
GRID=OFF,
STYLE=BOLD,
WRAP=0,

$
ENDSTYLE
END
-RUN



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
October 19, 2018, 07:56 AM
intsoccersuperstar
That works, thank you. I think I had an incomplete understanding of what TABLE HOLD can do. As you may have guessed, this is an existing report that I am "improving". Basically combining two reports into one so the business process down the line doesn't have to run multiple reports to get something that they just combine into a single Excel file anyway.


intsoccersuperstar
WebFOCUS 8105m
Windows, Excel
October 19, 2018, 09:17 AM
Doug
Also note the use of the -run statement used before any of the dialogue manager commands: -GOTO or -IF.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206