Focal Point
reading column-total as a field
June 16, 2008, 07:59 PM
serenekkreading column-total as a field
Hi All,
if I have a table like this with asnames=on:
TABLE FILE CAR
COUNT SALES
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
ON TABLE COLUMN-TOTAL AS 'TOTALCNT'
END
-RUN
can I read the TOTALCNT as variable from this run to be able to reuse this total count somewhere in the report?
on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
June 16, 2008, 10:59 PM
WazSerenekk
If you want the number of lines from the report use &LINES.
If you want to use the total of a field try this.
DEFINE FILE CAR
TOTALCNT/I9 WITH BODYTYPE = 1 ;
END
TABLE FILE CAR
SUM TOTALCNT
ON TABLE SAVE AS TOTCNT
END
-RUN
-READ TOTCNT &TOTALCNT.A9.
-TYPE Total Count = &TOTALCNT
Waz...Prod: | WebFOCUS 7.6.10/8.1.04 | Upgrade: | WebFOCUS 8.2.07 | OS: | Linux |
Outputs: | HTML, PDF, Excel, PPT |
In Focus since 1984 |
Pity the lost knowledge of an old programmer! |
June 17, 2008, 01:07 AM
Danny-SRLSerenekk,
TABLE FILE CAR
COUNT SALES
ON TABLE SAVE
END
-RUN
-READ SAVE,&SALECOUNT
Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
June 17, 2008, 08:55 AM
PBrightwellI think this will give you the output that you want.
SET ASNAMES=ON
TABLE FILE CAR
COUNT SALES AS 'TTL_CNT'
SUM CNT.SALES
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
ON TABLE HOLD AS CARCNT
END
?FF CARCNT
-EXIT
0 NUMBER OF RECORDS IN TABLE= 18 LINES= 18
FILENAME= CARCNT
TTL_CNT E01 I5
COUNTRY E02 A10
CAR E03 A16
MODEL E04 A24
BODYTYPE E05 A12
SALES E06 I5
Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
June 17, 2008, 10:42 AM
Darin Leequote:
can I read the TOTALCNT as variable from this run to be able to reuse this total count somewhere in the report?
The simple answer is no - column totals are not saved as part of any hold file. The AS phrase used in the ON TABLE COLUMN-TOTAL only modifies the label placed on the column-total line, it does not create any verb object that can be held. Since column-totals are not included in the hold file, it has no relevance.
That being said, there are a number of ways to still get the desired result as has been demonstrated.
You can use the &LINES or &RECORDS variables after creating your hold file.
You can use prefix operators such as TOT. or ST. to display the total count within headings,footings, subheadings, subfootings, etc.
You can perform a count and then read that back in as a variable using -READ.
You could even hold as format WP (this actually DOES save the COLUMN-TOTAL lines and then create a MASTER file to reread your output file and use define to find the column totals and somehow parse out the values you want.
So the long answer is yes, there is a way. Just not the way you had first envisioned. You'll get used to looked for several different ways to accomplish your task. The FOCUS language is great that way. Take your pick.
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