Focal Point
Technique for Lee from Mickey Grackin (HTML & PDF)

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

June 10, 2008, 11:33 AM
mgrackin
Technique for Lee from Mickey Grackin (HTML & PDF)
I realize the following may already be somewhere on Focal Point but I promised Lee I would post this code after Summit. Please let me know if you have any questions.

This is a technique that creates both an HTML and PDF output and HOLDs the PDF output on the WebFOCUS Client Temp Directory for a limited time so that it may be retrieved without rerunning the report. This presents the HTML output format to the user with a 'Printer Friendly' hyperlink to the PDF file.

WebFOCUS has a temporary directory which it uses to store files for a limited time. This directory is stored in the &CGI_TEMP_DIR WebFOCUS Client variable. The _TempFileTimeout setting controls how long files remain in this directory.

This technique takes advantage of the automatic cleanup of temporary files in order to make sure the PDF report files do not stay around forever. This technique assumes the WebFOCUS Client and WebFOCUS Server are installed on the same machine.

Step 1
Add a virtual directory called "ibi_temp" to the Web Server that points to the &CGI_TEMP_DIR. At my site we are using Microsoft IIS as teh Web Server.

Step 2
Add the following code to the SITE.WFS file in the WebFOCUS Client. This can be done by accessing the WebFOCUS Client Administration Panel and accessing Custom Settings under Configuration. This will setup a variable on the WebFOCUS Server (&IBITMP) to be used by the FOCEXEC to HOLD the PDF file output.

IBITMP=&CGI_TEMP_DIR
<set>IBITMP(pass)

Step 3
Create a FOCEXEC containing the following code that is accessible in the WebFOCUS Server APP PATH.

-*******************************************************************************
-* The following section should contain code that extracts the data needed for
-* the final output of the report.
-*******************************************************************************
TABLE FILE CAR
PRINT RETAIL_COST DEALER_COST
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
ON TABLE HOLD AS 'JUSTDATA'
END
-RUN
-*******************************************************************************
-* The following creates a random file name for the PDF file using the time of
-* day and a random number. This can be enhanced to use userid in the filename.
-*******************************************************************************
-SET &RANDOMNUM=ABS(RDUNIF('D9.7'))*1000000;
-SET &TIMEOFDAY=STRIP(8,&TOD,'.','A6');
-SET &PDFFILENAME=&TIMEOFDAY | (&RANDOMNUM || '.pdf');
-*******************************************************************************
-* The following adds the WebFOCUS TEMP directory to the APP PATH as PDFHOLD and
-* then does a FILEDEF to force the PDF HOLD file to be saved in PDFHOLD.
-*******************************************************************************
APP MAP PDFHOLD &IBITMP
APP FI PDF_FILE DISK PDFHOLD/&PDFFILENAME
-RUN
-*******************************************************************************
-* The following section creates the PDF file.
-*******************************************************************************
TABLE FILE JUSTDATA
PRINT RETAIL_COST DEALER_COST
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE NOPAGE
ON TABLE HOLD AS 'PDF_FILE' FORMAT PDF
ON TABLE SET STYLE *
TYPE=REPORT, ORIENTATION=LANDSCAPE, SQUEEZE=ON,$
TYPE=TITLE, BORDER=LIGHT, BACKCOLOR=NAVY, COLOR=WHITE,$
TYPE=DATA, BORDER=LIGHT,$
ENDSTYLE
END
-RUN
-*******************************************************************************
-* The following section creates the HTML output with a link to the PDF file in
-* the HEADING of the HTML output.
-*******************************************************************************
TABLE FILE JUSTDATA
PRINT RETAIL_COST DEALER_COST
COMPUTE PDFVERSION/A75='<A HREF=/ibi_temp/&PDFFILENAME..>Printer Friendly Version</A>'; NOPRINT
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
HEADING
"<PDFVERSION"
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE NOPAGE
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET STYLE *
TYPE=TITLE, BORDER=LIGHT, BACKCOLOR=NAVY, COLOR=WHITE,$
TYPE=DATA, BORDER=LIGHT,$
ENDSTYLE
END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011