Focal Point
[SOLVED] Compound Report - breakdown of tables

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

March 07, 2012, 06:02 AM
MNaumann
[SOLVED] Compound Report - breakdown of tables
I'd like to develop a compound report, which consists of several pieces, which seems possible at first sight.
In this report, a user has to choose a country. For this country, I'd like to see:
- The specifications for every single carmodel
- The salesfigures for every single carmodel

Obviously, WebFOCUS tend to print ALL specifications first for ALL models, and then prints ALL salesfigures for ALL carmodels.

How can I enhance the code such, that the compound report is broken down and prints correctly per carmodel? The Code:
[

-* File Car_compound.fex
SET COMPOUND = OPEN NOBREAK
TABLE FILE CAR
BY CAR NOPRINT
ON TABLE SUBHEAD
"Detail information for country "text"
"text"
" "
WHERE COUNTRY EQ 'JAPAN';
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF
END

-* Report 1

TABLE FILE CAR
SUM
SEATS
DEALER_COST
BY CAR NOPRINT PAGE-BREAK
BY MODEL
WHERE COUNTRY EQ 'JAPAN';
HEADING
"Specifications for model "text "
"text "
""
FOOTING
"text about this car"
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF
END

-* Report 2

SET COMPOUND = CLOSE
TABLE FILE CAR
SUM
RETAIL_COST
SALES
BY CAR NOPRINT PAGE-BREAK
BY MODEL
WHERE COUNTRY EQ 'JAPAN';
HEADING
"Sales figures for model FOOTING
"Rundate <+0>&DATED<+0>-<+0>&DATEM<+0>-<+0>&DATEYY<+0> om <+0>&TOD"
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF CLOSE
END
]

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


WebFOCUS 7.6.9
March 07, 2012, 03:45 PM
Waz
If you need to merge the sales figures with the specifications, then I can think of two ways to do this.

1. Create a loop with Dialog Manager inside the compound report, so each part only reports on the same level of data.

2. Use co-ordinated compound report, this has an option to merge on the highest sort field.

Depending on how simple the data is, you may be able to get away with joining you data together and use a single TABLE FILE with appropriate SUBHEADs ad SUBFOOTs.


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!

March 08, 2012, 07:28 PM
Crymsyn
This isn't the nicest looking since getting the columns named will be difficult but is a way. It uses the MacGyver master file to duplicate rows.

Also making a hold file before is not needed unless like in this case is more than one data path like this example with CAR is.

* File Car_compound.fex
-SET &COUNTRY='JAPAN';

TABLE FILE CAR
SUM
SEATS
RETAIL_COST
DEALER_COST
SALES
BY CAR
BY MODEL
ON TABLE HOLD AS CARHOLD
END

-*MacGyver 
FILEDEF MCGMAS DISK MACGYVER.MAS
FILEDEF MCGDAT DISK MACGYVER.DAT
-RUN
-WRITE MCGMAS FILE=MACGYVER,SUFFIX=FOC
-WRITE MCGMAS SEGNAME=MAC1,SEGTYPE=S1
-WRITE MCGMAS   FIELD=BLANK  ,     ,A1,INDEX=I,$
-WRITE MCGMAS SEGNAME=MAC2,SEGTYPE=S1,PARENT=MAC1
-WRITE MCGMAS   FIELD=COUNTER,ORDER,I4,$
-RUN

-*Replace the 2 in the line: FIXFORM 2(CTR/4 X-4) : To increase how many duplicate lines
 CREATE FILE MACGYVER
 MODIFY FILE MACGYVER
 COMPUTE CTR/I9=;
 FIXFORM 2(CTR/4 X-4)
 COMPUTE
   BLANK=' ';
   COUNTER=IF COUNTER EQ 0 THEN CTR ELSE COUNTER+1;
 MATCH BLANK
    ON MATCH CONTINUE
    ON NOMATCH INCLUDE
 MATCH COUNTER
    ON MATCH CONTINUE
    ON NOMATCH INCLUDE
 DATA
1
 END
-RUN

JOIN
BLANK WITH CAR IN CARHOLD TO
BLANK IN MACGYVER AS B_
END

DEFINE FILE CARHOLD
BLANK/A1 WITH CAR=' ';

COLUMN_ONE/I7=IF COUNTER EQ 1 THEN SEATS ELSE RETAIL_COST;
COLUMN_TWO/I7=IF COUNTER EQ 1 THEN DEALER_COST ELSE SALES;
END

TABLE FILE CARHOLD
PRINT
COLUMN_ONE
COLUMN_TWO

BY COUNTER NOPRINT
BY CAR NOPRINT
BY MODEL

ON COUNTER SUBHEAD
"Specifications for model"
"text "
""
WHEN COUNTER EQ 1;

ON COUNTER SUBHEAD
"Sales figures for model "
WHEN COUNTER EQ 2;

ON COUNTER SUBFOOT
""

HEADING
"Detail information for country &COUNTRY"
"text"
" "
FOOTING
"Rundate <+0>&DATED<+0>-<+0>&DATEM<+0>-<+0>&DATEYY<+0> om <+0>&TOD"
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE PCHOLD FORMAT PDF
END
-EXIT



WF: 8201, OS: Windows, Output: HTML, PDF, Excel
March 16, 2012, 05:12 AM
MNaumann
Thanks for your solutions. The loop option was the answer, we created this code. As you can mention the tricky part was to close the pdf document as the last record was read, so this is a variable line. Case is closed!

-SET &COUNTRY = 'JAPAN'

TABLE FILE CAR
PRINT
MODEL
BY MODEL NOPRINT
WHERE COUNTRY EQ '&COUNTRY';
ON TABLE HOLD AS HLD_FILE1 FORMAT ALPHA
END

-RUN
-SET &TELLER = 1;
-SET &AANT_LOOP = &LINES;


SET COMPOUND = OPEN NOBREAK
TABLE FILE CAR
BY CAR NOPRINT
WHERE COUNTRY EQ '&COUNTRY';
ON TABLE SUBHEAD
"Detail information for country "text"
"text"
" "
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF
END


-REPEAT :LEES_MODEL &AANT_LOOP TIMES
-READ HLD_FILE1 &MODEL.A24.
-TYPE &MODEL

-SET &VAR_CMP = IF &TELLER EQ &AANT_LOOP THEN CLOSE ELSE OPEN;

-* Report 1

TABLE FILE CAR
SUM
SEATS
DEALER_COST
BY CAR NOPRINT PAGE-BREAK
BY MODEL
WHERE MODEL EQ '&MODEL';
WHERE COUNTRY EQ '&COUNTRY';
HEADING
"Specifications for model "text "
"text "
""
FOOTING
"text about this car"
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF
END

-* Report 2

SET COMPOUND = &VAR_CMP
TABLE FILE CAR
SUM
RETAIL_COST
SALES
BY CAR NOPRINT PAGE-BREAK
BY MODEL
WHERE MODEL EQ '&MODEL';
WHERE COUNTRY EQ '&COUNTRY';
HEADING
"Sales figures for model FOOTING
"Rundate <+0>&DATED<+0>-<+0>&DATEM<+0>-<+0>&DATEYY<+0> om <+0>&TOD"
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF

END

-SET &TELLER = &TELLER + 1;
-:LEES_MODEL


WebFOCUS 7.6.9