Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Help with looping through a multiple-PDF file save

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Help with looping through a multiple-PDF file save
 Login/Join
 
Member
posted
We have one PDF report that needs to be saved in 2 separate network folders. I'm trying to do it in a one-pass fex.

The folders are set up and I can save files to them, as already tested. I can't get the loop logic to work and I'm not sure why, was hoping you could help.

Since looping logic in FOCUS is new to me, I've been reading the documentation and forum posts... this was the post most recently that I modeled the logic from:
PDF with REPEAT

At the start of the fex, I declare the two network folder paths:

 
-SET &FullDate = EDIT(&YYMD, '$$999999');
APP FI PDFPOC1 DISK \\Phibuilddev1\POC\MidnightImpatientStay.pdf
APP FI PDFPOC2 DISK \\Phibuilddev1\POC\Archive\&FullDate|_MidnightImpatientStay.pdf
-RUN 


This sets the path for one PDF to be saved to a 'current' directory, and a duplicate to be saved to an 'archive' folder.

The looping logic I'm trying looks like this:

 
-**  Final Report for 212PatientDaysReport 

-SET &Cnt = 1;
-REPEAT :Loop 2 TIMES;
-SET &Compound = IF &Cnt EQ 1 THEN 'PDFPOC1' ELSE IF &Cnt NE 1 THEN 'PDFPOC2';

-:Loop
TABLE FILE 212PATDAYS1
SUM
  COMPUTE PATDAYS/D5 = PATDAYS; AS 'Month Actual'
  NumMonthlyTarget AS 'Month Target'
  MonthlyVariance AS 'Variance'
  MonthlyPercentVariance AS '% Variance'
  COMPUTE YTDPATDAYS/D5 = YTDPATDAYS; AS 'YTD Actual'
  NumYTDTarget AS 'YTD Target'
  YTDVariance AS 'Variance'
  YTDPercentVariance AS '% Variance'
  FiscalMonth AS '' NOPRINT
BY Category NOPRINT
BY Order NOPRINT
BY REGIONNAME AS ''
BY Grouper ROWS 'Adult & Peds (no Psych or Rehab)' OVER 'Adult & Peds Psych' OVER 'Adult & Peds Rehab'
   OVER 'Adult & Peds Total' OVER 'Nursery' OVER 'Grand Total'
WHERE MonthDatetime LE DT(&completeddate);
ON TABLE SAVE FORMAT PDF AS &Compound
-SET &Cnt = &Cnt + 1;
 


When the code runs, it only runs for the first SAVE location, not the second. What am I doing wrong that it's not looping through correctly?

Any help is greatly appreciated Smiler

Thanks so much

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


WebFOCUS v. 7.6.10
___________________
Win2k3 Server
Intel Xeon 2.3Ghz/4Gb Ram Apache / IIS / SQL Srvr 2005
 
Posts: 29 | Location: Bellingham, WA | Registered: October 01, 2008Report This Post
Expert
posted Hide Post
Why not just use an OS command to copy the pdf document to the other location.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Member
posted Hide Post
quote:
OS command

lol, one more thing I guess that I haven't heard of. I'll check the documentation for it then and see what I can learn.

Thanks again!


WebFOCUS v. 7.6.10
___________________
Win2k3 Server
Intel Xeon 2.3Ghz/4Gb Ram Apache / IIS / SQL Srvr 2005
 
Posts: 29 | Location: Bellingham, WA | Registered: October 01, 2008Report This Post
Member
posted Hide Post
Wait, do you mean OS Command as in a FOCUS command, or were you suggesting something like an x-copy through a windows batch file?

I know I can write a .NET C# app that would do it, but we were hoping to encapuslate this completely within FOCUS so that there's one less thing to maintain when we schedule the reports.


WebFOCUS v. 7.6.10
___________________
Win2k3 Server
Intel Xeon 2.3Ghz/4Gb Ram Apache / IIS / SQL Srvr 2005
 
Posts: 29 | Location: Bellingham, WA | Registered: October 01, 2008Report This Post
Expert
posted Hide Post
quote:
OS Command


APP FI PDFPOC DISK \\Phibuilddev1\POC\MidnightImpatientStay.pdf
-RUN
TABLE FILE 212PATDAYS1
SUM
  COMPUTE PATDAYS/D5 = PATDAYS; AS 'Month Actual'
  NumMonthlyTarget AS 'Month Target'
  MonthlyVariance AS 'Variance'
  MonthlyPercentVariance AS '% Variance'
  COMPUTE YTDPATDAYS/D5 = YTDPATDAYS; AS 'YTD Actual'
  NumYTDTarget AS 'YTD Target'
  YTDVariance AS 'Variance'
  YTDPercentVariance AS '% Variance'
  FiscalMonth AS '' NOPRINT
BY Category NOPRINT
BY Order NOPRINT
BY REGIONNAME AS ''
BY Grouper ROWS 'Adult & Peds (no Psych or Rehab)' OVER 'Adult & Peds Psych' OVER 'Adult & Peds Rehab'
   OVER 'Adult & Peds Total' OVER 'Nursery' OVER 'Grand Total'
WHERE MonthDatetime LE DT(&completeddate);
ON TABLE HOLD AS PDFPOC FORMAT PDF
END
-RUN
! COPY \\Phibuilddev1\POC\MidnightImpatientStay.pdf \\Phibuilddev1\POC\Archive\&FullDate|_MidnightImpatientStay.pdf


This could also be done with APP commands as well.

APP MAP PDFPOC1 \\Phibuilddev1\POC
APP MAP PDFPOC2 \\Phibuilddev1\POC\Archive

APP COPYFILE PDFPOC1 MidnightImpatientStay PDF PDFPOC2 &FullDate|_MidnightImpatientStay PDF


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Don't forget that, when using TABLE, the internal matrix is still available after the END statement and can still be acted upon -

APP FI PDFPOC DISK c:\ibi\apps\baseapp\pdfpoc.pdf
APP FI PDFPOC1 DISK c:\ibi\apps\baseapp\pdfpoc1.pdf
-RUN
TABLE FILE CAR
  SUM RCOST
      DCOST
   BY COUNTRY
   BY CAR
   BY MODEL
ON TABLE HOLD AS PDFPOC FORMAT PDF
END
HOLD AS PDFPOC1 FORMAT PDF
-RUN

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
Tony and Waz have expertly addressed your issue in a very efficient way.

To address a loop, -REPEAT is the "start" of the loop, the 2nd part is the "end" of the loop.

-REPEAT :loop 2 TIMES no semi-colon

So, to fix your code for future looping:

  
-SET &FullDate = EDIT(&YYMD, '$$999999');
APP FI PDFPOC1 DISK \\Phibuilddev1\POC\MidnightImpatientStay.pdf
APP FI PDFPOC2 DISK \\Phibuilddev1\POC\Archive\&FullDate|_MidnightImpatientStay.pdf
-RUN 

-**  Final Report for 212PatientDaysReport 

-SET &Cnt = 1;
-REPEAT :Loop 2 TIMES
-SET &Compound = IF &Cnt EQ 1 THEN 'PDFPOC1' ELSE 'PDFPOC2';

TABLE FILE 212PATDAYS1
SUM
  COMPUTE PATDAYS/D5 = PATDAYS; AS 'Month Actual'
  NumMonthlyTarget AS 'Month Target'
  MonthlyVariance AS 'Variance'
  MonthlyPercentVariance AS '% Variance'
  COMPUTE YTDPATDAYS/D5 = YTDPATDAYS; AS 'YTD Actual'
  NumYTDTarget AS 'YTD Target'
  YTDVariance AS 'Variance'
  YTDPercentVariance AS '% Variance'
  FiscalMonth AS '' NOPRINT
BY Category NOPRINT
BY Order NOPRINT
BY REGIONNAME AS ''
BY Grouper ROWS 'Adult & Peds (no Psych or Rehab)' OVER 'Adult & Peds Psych' OVER 'Adult & Peds Rehab'
   OVER 'Adult & Peds Total' OVER 'Nursery' OVER 'Grand Total'
WHERE MonthDatetime LE DT(&completeddate);
ON TABLE SAVE FORMAT PDF AS &Compound
END
-RUN
-SET &Cnt = &Cnt + 1;
-:Loop
-EXIT


You "may" need a fully qualified path in the APP FI command.

hth


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Member
posted Hide Post
wow, didn't know either of those options existed. I'm going to give them both a shot right now, thanks much for the responses guys!


WebFOCUS v. 7.6.10
___________________
Win2k3 Server
Intel Xeon 2.3Ghz/4Gb Ram Apache / IIS / SQL Srvr 2005
 
Posts: 29 | Location: Bellingham, WA | Registered: October 01, 2008Report This Post
Member
posted Hide Post
Tom, I tested the loop syntax as well, worked just fine with that change.

Thanks much everyone, the responses helped not just fix the problem but helped with some good instruction I didn't see elsewhere when searching. Appreciate it much.


WebFOCUS v. 7.6.10
___________________
Win2k3 Server
Intel Xeon 2.3Ghz/4Gb Ram Apache / IIS / SQL Srvr 2005
 
Posts: 29 | Location: Bellingham, WA | Registered: October 01, 2008Report This Post
Expert
posted Hide Post
Just keep in mind that in WebFOCUS there are many ways to skin the proverbial cat.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Also keep in mind that with the loop syntax, you are processing the file twice, if it is from a large table/join structure the program will be doing a lot of work twice.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Member
posted Hide Post
yeah, thought of that. the loop broke the compound fex anyways, so we went with the COPY command at the end of the compound and it worked fine.

Sure appreciated the help, too Smiler


WebFOCUS v. 7.6.10
___________________
Win2k3 Server
Intel Xeon 2.3Ghz/4Gb Ram Apache / IIS / SQL Srvr 2005
 
Posts: 29 | Location: Bellingham, WA | Registered: October 01, 2008Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Help with looping through a multiple-PDF file save

Copyright © 1996-2020 Information Builders