Focal Point
[SOLVED] Suppressing Pages in a PDF Compound Report

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

October 05, 2017, 11:38 AM
kfreers
[SOLVED] Suppressing Pages in a PDF Compound Report
We have a request from a customer to allow them to add pages to the end of their invoices based on a value in a field.

I put together an example using the car file that should help show what we are trying to do. In my example, I have 8 records that I am pulling from the Car File that I need to create an invoice from. If the record has the Country of 'England' or 'France', a second page needs to be added to the invoice. Currently, when you run the report, it returns 24 pages because it's adding Page 2 & 3 to every record. Ideally, we need the report to return 10 total pages. There should be 2 pages for the England record and 2 pages for the France record and then 1 page for the six other records.

Can this be accomplished using the PDF Compound report logic? If not, does anyone else have any ideas. The first page of the invoice is working great and we have it completely finished using the compound report objects and components. It's the additional pages needed on only certain records that's causing the issue.

Thanks,

Keith

DEFINE FILE CAR
BATCH/A3=FPRINT(SEATS,'I3',BATCH);
INVOICE/A16=CAR;
REFVALUE_1/I8=SALES+LENGTH+WIDTH+HEIGHT+WEIGHT;
REFVALUE/A8=FPRINT(REFVALUE_1,'I8',REFVALUE);
BATCH_INVOICE_REFVALUE/A50=BATCH||'_'||INVOICE||'_'||REFVALUE ;
END

TABLE FILE CAR
PRINT *
BATCH
INVOICE
REFVALUE
BATCH_INVOICE_REFVALUE
BY REFVALUE
ON TABLE HOLD AS BJ_CAR
END

COMPOUND LAYOUT PCHOLD FORMAT PDF
UNITS=IN, $
SECTION=BILLABLE_INVOICE, LAYOUT=ON, MERGE=ON, $

PAGELAYOUT=1,TOPMARGIN=0.1, RIGHTMARGIN=0.1, LEFTMARGIN=0.1,BOTTOMMARGIN=0.1, $
OBJECT=BOX,POSITION=(.1 .1),DIMENSION=(8.3 10.8),border-color=black,$
COMPONENT='INVOICE_01',TYPE=REPORT,POSITION=(1 1), DIMENSION=(7 3),$
COMPONENT='INVOICE_02',TYPE=REPORT,POSITION=(1 5), DIMENSION=(4 2),$

PAGELAYOUT=2,TOPMARGIN=0.1, RIGHTMARGIN=0.1, LEFTMARGIN=0.1,BOTTOMMARGIN=0.1, $
OBJECT=BOX,POSITION=(.1 .1),DIMENSION=(8.3 10.8),border-color=black,$
COMPONENT='ENGLAND_NOTE',TYPE=REPORT,POSITION=(1 1), DIMENSION=(7 2),$

PAGELAYOUT=3,TOPMARGIN=0.1, RIGHTMARGIN=0.1, LEFTMARGIN=0.1,BOTTOMMARGIN=0.1, $
OBJECT=BOX,POSITION=(.1 .1),DIMENSION=(8.3 10.8),border-color=black,$
COMPONENT='FRANCE_NOTE',TYPE=REPORT,POSITION=(1 1), DIMENSION=(7 2),$
END


SET COMPONENT='INVOICE_01'
TABLE FILE BJ_CAR
HEADING
"<13>BATCH ID:"<14>INVOICE #:"<15>COUNTRY:"<16>CAR: "<17>MODEL: "<18>REF VALUE: ""
"<5>BY FIELD VALUE:BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE SEATS EQ 5;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
-*type=report,line=1,justify=center,$
ENDSTYLE
END

-*
SET COMPONENT='INVOICE_02'
TABLE FILE BJ_CAR
HEADING
"<17>DEALER COST:"<17>RETAIL COST:"<17>SALES:BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE SEATS EQ 5;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END

SET COMPONENT='ENGLAND_NOTE'
TABLE FILE BJ_CAR
COMPUTE X/I2 = TABPAGENO;
HEADING
"This Page should only show up if the Country is England."
BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE SEATS EQ 5;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END

SET COMPONENT='FRANCE_NOTE'
TABLE FILE BJ_CAR
COMPUTE X/I2 = TABPAGENO;
HEADING
"This Page should only show up if the Country is France."
BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE SEATS EQ 5;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8.104
Windows, All Outputs
October 05, 2017, 11:55 AM
Francis Mariani
Perhaps adding a filter will solve the problem?

SET COMPONENT='ENGLAND_NOTE'
TABLE FILE BJ_CAR
COMPUTE X/I2 = TABPAGENO;
HEADING
"This Page should only show up if the Country is England."
BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE

WHERE COUNTRY EQ 'ENGLAND';

WHERE SEATS EQ 5;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END

SET COMPONENT='FRANCE_NOTE'
TABLE FILE BJ_CAR
COMPUTE X/I2 = TABPAGENO;
HEADING
"This Page should only show up if the Country is France."
BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE

WHERE COUNTRY EQ 'FRANCE';

WHERE SEATS EQ 5;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END



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
October 05, 2017, 02:49 PM
kfreers
Francis,

Thanks for your quick response! I really appreciate it! It came back with 10 pages just like I wanted!

I have another question on this report. If I change my where statement with 'Batch' which is 'Seats' in this car file example, to 4 instead of 5, it puts the 'France' page at the beginning of the report because France doesn't have any cars with 4 seats. The rest of the report behaves as expected. I returns 7 pages instead of 6.

Is there any way to resolve the last component when there is no value for it in the data?

Thanks

Keith


Revised Code:

DEFINE FILE CAR
BATCH/A3=FPRINT(SEATS,'I3',BATCH);
INVOICE/A16=CAR;
REFVALUE_1/I8=SALES+LENGTH+WIDTH+HEIGHT+WEIGHT;
REFVALUE/A8=FPRINT(REFVALUE_1,'I8',REFVALUE);
BATCH_INVOICE_REFVALUE/A50=BATCH||'_'||INVOICE||'_'||REFVALUE ;
-*JUMPER/I2 = IF COUNTRY EQ 'ENGLAND' THEN 2 ELSE IF COUNTRY EQ 'FRANCE' THEN 3 ELSE 1;
END

TABLE FILE CAR
PRINT *
BATCH
INVOICE
REFVALUE
BATCH_INVOICE_REFVALUE
-*JUMPER
BY REFVALUE
ON TABLE HOLD AS BJ_CAR
END

COMPOUND LAYOUT PCHOLD FORMAT PDF
UNITS=IN, $
SECTION=BILLABLE_INVOICE, LAYOUT=ON, MERGE=ON, $

PAGELAYOUT=1,TOPMARGIN=0.1, RIGHTMARGIN=0.1, LEFTMARGIN=0.1,BOTTOMMARGIN=0.1, $
OBJECT=BOX,POSITION=(.1 .1),DIMENSION=(8.3 10.8),border-color=black,$
COMPONENT='INVOICE_01',TYPE=REPORT,POSITION=(1 1), DIMENSION=(7 3),$
COMPONENT='INVOICE_02',TYPE=REPORT,POSITION=(1 5), DIMENSION=(4 2),$

PAGELAYOUT=2,TOPMARGIN=0.1, RIGHTMARGIN=0.1, LEFTMARGIN=0.1,BOTTOMMARGIN=0.1, $
OBJECT=BOX,POSITION=(.1 .1),DIMENSION=(8.3 10.8),border-color=black,$
COMPONENT='ENGLAND_NOTE',TYPE=REPORT,POSITION=(1 1), DIMENSION=(7 2),$

PAGELAYOUT=3,TOPMARGIN=0.1, RIGHTMARGIN=0.1, LEFTMARGIN=0.1,BOTTOMMARGIN=0.1, $
OBJECT=BOX,POSITION=(.1 .1),DIMENSION=(8.3 10.8),border-color=black,$
COMPONENT='FRANCE_NOTE',TYPE=REPORT,POSITION=(1 1), DIMENSION=(7 2),$
END


SET COMPONENT='INVOICE_01'
TABLE FILE BJ_CAR
HEADING
"<13>BATCH ID:"<14>INVOICE #:"<15>COUNTRY:"<16>CAR: "<17>MODEL: "<18>REF VALUE: ""
"<5>BY FIELD VALUE:BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE SEATS EQ 4;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
-*type=report,line=1,justify=center,$
ENDSTYLE
END

-*
SET COMPONENT='INVOICE_02'
TABLE FILE BJ_CAR
HEADING
"<17>DEALER COST:"<17>RETAIL COST:"<17>SALES:BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE SEATS EQ 4;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END

SET COMPONENT='ENGLAND_NOTE'
TABLE FILE BJ_CAR
COMPUTE X/I2 = TABPAGENO;
HEADING
"This Page should only show up if the Country is England."
BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE COUNTRY EQ 'ENGLAND';
WHERE SEATS EQ 4;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END

SET COMPONENT='FRANCE_NOTE'
TABLE FILE BJ_CAR
COMPUTE X/I2 = TABPAGENO;
HEADING
"This Page should only show up if the Country is France."
BY BATCH_INVOICE_REFVALUE NOPRINT REPAGE
WHERE COUNTRY EQ 'FRANCE';
WHERE SEATS EQ 4;
ON BATCH_INVOICE_REFVALUE PAGE-BREAK
ON TABLE SET PAGE NOPAGE
ON TABLE SET STYLE *
type=report,size=7,$
ENDSTYLE
END


WebFOCUS 8.104
Windows, All Outputs
October 05, 2017, 03:24 PM
Francis Mariani
There's the EMPTYREPORT option:

quote:
If a report request returns no records (for example, because no records satisfy its selection criteria, or because the data source has no records), you can choose to display or print:

An empty report, that is, the report without data but including column titles, a report heading (if one was specified in the report request), and a page heading (if one was specified).
To do this, set the EMPTYREPORT parameter to ON.

A message stating that there is no report output.
This is the default. You can return to the default by setting the EMPTYREPORT parameter to OFF

SET EMPTYREPORT = {ANSI|ON|OFF}

OFF is the default, but try adding ON TABLE SET EMPTYREPORT OFF in the ENGLAND_NOTE and FRANCE_NOTE components.

Though this may not work for a compound report. You may have to use Dialogue Manager code to loop through the values and bypass execution of the inappropriate compound report components, which makes it all more complicated than it needs to be.


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
October 05, 2017, 04:03 PM
kfreers
Francis,

That worked in the compound report example! Thanks again! You saved us on this one! We didn't anticipate this issue and our deadline is next Monday.

I have one more question based on the code that I sent you that hopefully you might have the answer to as well. Do you have any thoughts on how we could handle page numbers on each page? The customer wants 1 of 1, if it's only one invoice and 1 of 2, 2 of 2 if it's 2 pages. They need to reset based on every change in the 'BATCH_INVOICE_REFVALUE' value.

Thanks,

Keith


WebFOCUS 8.104
Windows, All Outputs
October 10, 2017, 06:08 PM
Doug
Check out TABPAGNO and TABLASTPAGE.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206