Focal Point
Compound PDF with a Loop?

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

March 30, 2007, 10:40 AM
Bethany
Compound PDF with a Loop?
I have a report that creates a compound PDF document based on a user submitted account unit. What I would like to do is to be able to create multiple compound PDF documents from a list of account units? Is there a way to do this with a loop?

List of account units:
110000
120000
130000

COMPOUND PDF 1 contains
Summary of 110000
Detail of 110000

COMPOUND PDF 2 contains
Summary of 120000
Detail of 120000

COMPOUND PDF 3 contains
Summary of 130000
Detail of 130000

Bethany
WF: 7.1.1
DevStudio 7.1.4


Server Environment: Win2K3 Server WebFOCUS 7.13 Apache Tomcat standalone application server
March 30, 2007, 10:52 AM
Francis Mariani
As far as I know, you can only create one compound PDF report per WF session, unless you FILEDEF them somewhere and HOLD them instead of PCHOLD them and then open them by some other means.


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
March 30, 2007, 11:00 AM
Prarie
Here is a stripped down version of something I've done with a compound PDF in a loop. Maybe it can give you some ideas.

TABLE FILE WHATEVER
BY SPLIT
WHERE SPLIT EQ &SPLIT
ON TABLE HOLD AS PARMFILE FORMAT ALPHA
END
-SET &REC_CNT = &LINES;
-SET &CNTR = 0;

-REPEAT LOOP &REC_CNT TIMES;
-READ PARMFILE &SPLIT.A8.
-TYPE &SPLIT
-SET &CNTR= &CNTR + 1;
-SET &CMP_FLG = IF &CNTR EQ &REC_CNT THEN 'CLOSE' ELSE 'OPEN';

SET COMPOUND = OPEN
TABLE FILE WHATEVER
SUM
CALLSOFFERED AS 'Calls,Offer'

WHERE SPLIT EQ &SPLIT;
END
-*********************************** REPORT2 *************************************
-SET &CMP_FLG = IF &CNTR EQ &REC_CNT THEN 'CLOSE' ELSE 'OPEN';
SET COMPOUND = &CMP_FLG
TABLE FILE WHATEVER
PRINT SPLIT

IF SPLIT EQ &SPLIT
ON TABLE PCHOLD FORMAT PDF

END
-LOOP


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Can you use report caster and the burst option here anyone? I've never tried it.


Leah
We do this with Report Caster and bursting as Leah mentioned, using FTP to distribute the multiple output documents burst on a market sector. I don't think there is any other way to generate multiple PDF documents in one session. Of course, if they can all be in the same document, we use something similar to Prarie's code.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
Bethany,
What do you want to achieve? One output containing all the data of all the accounts or many different outputs? And where would the output(s) go, to the screen, a printer, different files?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

quote:
110000
120000
130000

I have done a few compound PDF reports similar to yours. The first step is you save your list of account (110000 120000 130000) to a text file. Within the REPEAT statement, you use -READ SAVE NOCLOSE ... to get one account at a time. Base on the account read from the saved file, you dynamically construct SUM statement and WHERE statement. You also need dynamically construct FORMAT PDF portion of that (ON TABLE HOLD FORMAT PDF OPEN) statement (separate that statement into two 2 lines in order to code easier). The first account is FORMAT PDF OPEN, and the last account is FORMAT PDF CLOSE.
I this what you are wanting to accomplish only with PDF?

FILEDEF CNTRL DISK /edadata/cntrl.dat
-SET &CNTR = 1;
-SET &CNTRC = 0;
-*
-SET &CNTRY = '';
FILEDEF TTEXT DISK /edadata/ttext.dat
DEFINE FILE CAR
CNTRC/I9 = IF COUNTRY EQ LAST COUNTRY THEN LAST CNTRC ELSE CNTRC + 1;
END
-*
TABLE FILE CAR
SUM LST.CNTRC
ON TABLE SAVE AS CNTRL FORMAT ALPHA
END
-*
FILEDEF CNTRL DISK /edadata/cntrl.dat
-RUN
-READ CNTRL, &CNTRC
-*
-REDO
-*
-SET &CNTRY = '';
DEFINE FILE CAR
CNTRC/I9 = IF COUNTRY EQ LAST COUNTRY THEN LAST CNTRC ELSE CNTRC + 1;
CNTRY/A10 = COUNTRY;
END
-*
TABLE FILE CAR
PRINT CNTRY
BY CNTRC NOPRINT
WHERE CNTRC EQ &CNTR
WHERE RECORDLIMIT EQ 1
ON TABLE SAVE AS TTEXT FORMAT ALPHA
END
-*
FILEDEF TTEXT DISK /edadata/ttext.dat
-RUN
-READ TTEXT, &CNTRY
-*
DEFINE FILE CAR
CNTR/I9 = IF COUNTRY EQ LAST COUNTRY THEN LAST CNTR ELSE CNTR + 1;
COUNTRY1/A10 = '&CNTRY';
END
-*
TABLE FILE CAR
SUM
DEALER_COST
RETAIL_COST
BY COUNTRY
WHERE CNTR EQ &CNTR
ON TABLE SET STYLE *
TYPE=REPORT, TITLETEXT=SUMMARY FOR &CNTRY, $
TYPE=HEADING, SIZE=18, $
ENDSTYLE
-IF &CNTR = 1 THEN GOTO THEOPEN;
-IF &CNTR EQ &CNTRC THEN GOTO THECLOSE;
-CONTINUE
ON TABLE PCHOLD FORMAT EXL2K
END
-GOTO SETTER
-THEOPEN
ON TABLE PCHOLD FORMAT EXL2K OPEN
END
-GOTO SETTER
-THECLOSE
ON TABLE PCHOLD FORMAT EXL2K CLOSE
END
-GOTO SETTER
-SETTER
-SET &CNTR = &CNTR + 1;
-IF &CNTR = 6 THEN GOTO STOPPER;
-GOTO REDO
-STOPPER
-EXIT


Glenda

In FOCUS Since 1990
Production 8.2 Windows