Focal Point
[CLOSED] Looping through pdf form

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

September 18, 2015, 10:28 AM
Nyssa Darter
[CLOSED] Looping through pdf form
I have a pdf form that I created in composer which is just populated with variables pulled from a SQL database. I created three variations based on whether the pdf should be open, close or blank depending on how many sets of variables are returned. I can only get the pdf to generate the first page of the report even though I loop through the code. Can someone take a look at this code and tell me what I am doing wrong? Do I have to hold this file somewhere to get the other pages to generate?

-*Grab all the school group reservations for the previous day and put them in a HOLD file
ENGINE SQLMSS SET DEFAULT_CONNECTION OutboundSoftwareZoo
SQL SQLMSS PREPARE SQLOUT FOR
SELECT CAST(row_number() over(order by R.ResID) AS INT) AS ID,CAST(CONVERT(DATE,A.ActDateTime,101) AS CHAR(10)) AS VISIT,CAST(R.ResName AS CHAR(56)) AS ORGANIZATION,
CAST((C.FirstName +' '+ C.LastName) AS CHAR(52)) AS CAREOF,CAST(C.[Street 1] AS CHAR(56)) AS ADDRESS,CAST((C.City + ', ' + C.State + ' ' + C.Zip) AS CHAR(85)) AS CITYSTATE,
CAST(C.[Home Phone] AS CHAR(31)) AS PHONE,CAST(CASE WHEN A.ActivityID = '1828' THEN 'Franklin' ELSE 'Non-Franklin' END AS CHAR(18)) AS COUNTY,CAST(A.DisplayTimeLabel AS CHAR(56)) AS TIME
FROM Reservations AS R JOIN Activities AS A ON R.ResID = A.ResID JOIN Customers AS C ON R.CustomerID = C.Customer#
WHERE R.ResDateCreated BETWEEN '20150917' AND DATEADD(d,1,'20150917')
AND (A.ActivityID = '1828' OR A.ActivityID = '1829') ORDER BY R.ResID
END
-RUN
TABLE FILE SQLOUT
PRINT *
BY ID
ON TABLE HOLD AS SCH_LIST
END
-SET &COUNTER = &LINES;
-*------------------------------LOOP-----------------------------------
-REPEAT LOOP &COUNTER TIMES;
-*-SET &CMP_FLG = IF &LOOP EQ &COUNTER THEN 'CLOSE' ELSE IF &LOOP EQ 1 THEN 'OPEN' ELSE '';
TABLE FILE SCH_LIST
PRINT ID VISIT ORGANIZATION CAREOF ADDRESS CITYSTATE PHONE COUNTY TIME
WHERE ID = &LOOP;
ON TABLE SAVE AS SCH_FORM
END
-RUN
-READ SCH_FORM &ID.I11. &VISIT.A10. &ORGANIZATION.A56. &CAREOF.A52. &ADDRESS.A56. &CITYSTATE.A85. &PHONE.A31. &COUNTY.A18. &TIME.A56.
-TYPE &ID
-TYPE &ORGANIZATION
-TYPE &CAREOF
-TYPE &ADDRESS
-TYPE &CITYSTATE
-TYPE &VISIT
-TYPE &TIME
-TYPE &COUNTY
-TYPE &PHONE
-TYPE &EXTRA
-TYPE &LOOP
-TYPE &COUNTER
-*Create the pdf form for this school group
-IF &LOOP EQ 1 GOTO OPEN ELSE IF &LOOP EQ &COUNTER GOTO CLOSE ELSE GOTO MIDDLE;
-OPEN
-INCLUDE schoolgroups_forma.fex
-GOTO FORMOUT
-MIDDLE
-INCLUDE schoolgroups_formb.fex
-GOTO FORMOUT
-CLOSE
-INCLUDE schoolgroups_formc.fex
-FORMOUT
-SET &LOOP = &LOOP + 1;
-*------------------------------ END LOOP-----------------------------------
END
-LOOP

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8.04
Windows 7, All Outputs

September 18, 2015, 11:05 AM
j.gross
How do you know how many columns ID spans?

You could simplify things considerably (avoiding the SAVE step), by using -READFILE in the loop.


- Jack Gross
WF through 8.1.05
September 18, 2015, 11:51 AM
Nyssa Darter
I am not sure what you mean by columns. Good idea I will definitely make that change.


WebFOCUS 8.04
Windows 7, All Outputs