This is a multi-part message in MIME format.
--------------13D91A02BAD8C325C58D7B80
Content-Type: multipart/alternative; boundary="------------8E7B7F17F3A6CC5939E5BFB3"
--------------8E7B7F17F3A6CC5939E5BFB3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I ran into some problems printing footings on duplex reports. I'd like
to share my solution with you in case any of you run into a similar
situation.
I started with the following duplex report logic for a report with a
control break by 1 key item:
ACCESS file
SET PAGE LENGTH 48
DEFINE P-27 INT*2 = 27
DEFINE P-ESC CHAR*1 = CHAR(P-27)[2:1]
DEFINE P-BACK CHAR*5 = P-ESC + "&a2G"
SORT ON key-field
PAGE HEADING SKIP PAGE TAB 01 "Header Line"
HEADING AT key-field SKIP PAGE
REPORT key-field data-field1 data-field2 ......
FOOTING AT key-field P-BACK
The HEADING AT statement has a SKIP PAGE which advances to the front of
the next page when a control break occurs on 'key-field'. The FOOTING
AT statement advances to the back of the page when a control break
occurs on 'key-field'. So when a control break occurs and the last
REPORT line is on the front side of the page, it skips to the front of
the next blank page. When a control break occurs and the last REPORT
line is on the back side of the page, it will generate a blank sheet of
paper and skip to the front side of a new page.
To add footings, I added the following statement:
PAGE FOOTING SKIP 2 TAB 01 "Footing Line"
This worked just fine except at the control break. In QUIZ, the PAGE
FOOTING logic is executed after all FOOTING AT statements (unless my
assumption is wrong). So when a control break occurs, the FOOTING AT
statement advances to the back of the current page and then the PAGE
FOOTING prints. What I wanted was the PAGE FOOTING first followed by
the skip to the back of the page.
To get around this, I had to pass the data one more time. I created a
second control break item called 'page-break-num'. This field contains
a unique number for each group of data records that will fit on a page
and is reset to 1 at each control break by 'key-field':
:QTP
ACCESS file
TEMP rec-num ZONED*8
TEMP page-break-num ZONED*8
SORT ON key-field
ITEM rec-num = rec-num + 1 RESET AT key-field TO 34
(NOTE: 34 is the maximum number of data lines per page minus 1.
It does not include heading or footing line
counts)
ITEM page-break-num = rec-num / 35
SUBFILE file2 KEEP INCLUDE file, page-break-num
Then I changed the QUIZ program to the following:
ACCESS file2
SET PAGE LENGTH 48
DEFINE P-27 INT*2 = 27
DEFINE P-ESC CHAR*1 = CHAR(P-27)[2:1]
DEFINE P-BACK CHAR*5 = P-ESC + "&a2G"
SORTED ON key-field, page-break-num
PAGE HEADING SKIP PAGE TAB 01 "Header Line"
HEADING AT key-field SKIP PAGE
REPORT key-field data-field1 data-field2 ......
FOOTING AT page-break-num SKIP 2 TAB 01 "Footing Line"
FOOTING AT key-field P-BACK
This worked in all cases except when the last page printed for
'key-field' contained exactly 35 lines (maximum number of data lines for
the report). In this case, it skipped to the next page, printed the
PAGE HEADING and then executed the FOOTING AT key-field P-BACK
statement. This made it look like there were more records to be printed
for key-field when there weren't any. This was worse than the original
problem.
Finally, I removed the PAGE HEADING statement and replaced it with a
PAGE HEADING AT page-break-num. This solved all of the problems. The
final code is as follows:
ACCESS file2
SET PAGE LENGTH 48
SET NOHEAD FORMFEED
(Note: NOHEAD turns off the default page headers and all
carriage control)
( FORMFEED turns carriage control back on--without
this, SKIP PAGE logic
does not work)
DEFINE P-27 INT*2 = 27
DEFINE P-ESC CHAR*1 = CHAR(P-27)[2:1]
DEFINE P-BACK CHAR*5 = P-ESC + "&a2G"
SORTED ON key-field, page-break-num
HEADING AT page-break-num SKIP PAGE TAB 01 "Header Line"
HEADING AT key-field SKIP PAGE
REPORT key-field data-field1 data-field2 ......
FOOTING AT page-break-num SKIP 2 TAB 01 "Footing Line"
FOOTING AT key-field P-BACK
I hope this is helpful. If anyone has any other suggestions, they would
be appreciated.
Carol
(PH 7.29.C8 / MPE/ix 5.5)
--------------8E7B7F17F3A6CC5939E5BFB3
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
I ran into some problems printing footings on duplex reports. I'd
like to share my solution with you in case any of you run into a similar
situation.
I started with the following duplex report logic for a report with a
control break by 1 key item:
ACCESS file
SET PAGE LENGTH 48
DEFINE P-27 INT*2 = 27
DEFINE P-ESC CHAR*1 = CHAR(P-27)[2:1]
DEFINE P-BACK CHAR*5 = P-ESC + "&a2G"
SORT ON key-field
PAGE HEADING SKIP PAGE TAB 01 "Header Line"
HEADING AT key-field SKIP PAGE
REPORT key-field data-field1 data-field2 ......
FOOTING AT key-field P-BACK
The HEADING AT statement has a SKIP PAGE which advances to the front
of the next page when a control break occurs on 'key-field'. The
FOOTING AT statement advances to the back of the page when a control break
occurs on 'key-field'. So when a control break occurs and the last
REPORT line is on the front side of the page, it skips to the front of
the next blank page. When a control break occurs and the last REPORT
line is on the back side of the page, it will generate a blank sheet of
paper and skip to the front side of a new page.
To add footings, I added the following statement:
PAGE FOOTING SKIP 2 TAB 01 "Footing Line"
This worked just fine except at the control break. In QUIZ, the
PAGE FOOTING logic is executed after all FOOTING AT statements (unless
my assumption is wrong). So when a control break occurs, the FOOTING
AT statement advances to the back of the current page and then the PAGE
FOOTING prints. What I wanted was the PAGE FOOTING first followed
by the skip to the back of the page.
To get around this, I had to pass the data one more time. I created
a second control break item called 'page-break-num'. This field contains
a unique number for each group of data records that will fit on a page
and is reset to 1 at each control break by 'key-field':
:QTP
ACCESS file
TEMP rec-num ZONED*8
TEMP page-break-num ZONED*8
SORT ON key-field
ITEM rec-num = rec-num +
1 RESET AT key-field TO 34
(NOTE: 34 is the maximum
number of data lines per page minus 1.
It does not include heading or footing line counts)
ITEM page-break-num = rec-num
/ 35
SUBFILE file2 KEEP INCLUDE
file, page-break-num
Then I changed the QUIZ program to the following:
ACCESS file2
SET PAGE LENGTH 48
DEFINE P-27 INT*2 = 27
DEFINE P-ESC CHAR*1 = CHAR(P-27)[2:1]
DEFINE P-BACK CHAR*5 = P-ESC + "&a2G"
SORTED ON key-field, page-break-num
PAGE HEADING SKIP PAGE TAB 01 "Header Line"
HEADING AT key-field SKIP PAGE
REPORT key-field data-field1 data-field2 ......
FOOTING AT page-break-num
SKIP 2 TAB 01 "Footing Line"
FOOTING AT key-field P-BACK
This worked in all cases except when the last page printed for 'key-field'
contained exactly 35 lines (maximum number of data lines for the report).
In this case, it skipped to the next page, printed the PAGE HEADING and
then executed the FOOTING AT key-field P-BACK statement. This made
it look like there were more records to be printed for key-field when there
weren't any. This was worse than the original problem.
Finally, I removed the PAGE HEADING statement and replaced it with a
PAGE HEADING AT page-break-num. This solved all of the problems.
The final code is as follows:
ACCESS file2
SET PAGE LENGTH 48
SET NOHEAD FORMFEED
(Note: NOHEAD turns off the default page headers and all carriage
control)
( FORMFEED
turns carriage control back on--without this, SKIP PAGE logic
does not work)
DEFINE P-27 INT*2 = 27
DEFINE P-ESC CHAR*1 = CHAR(P-27)[2:1]
DEFINE P-BACK CHAR*5 = P-ESC + "&a2G"
SORTED
ON key-field, page-break-num
HEADING AT page-break-num
SKIP PAGE TAB 01 "Header Line"
HEADING AT key-field SKIP PAGE
REPORT key-field data-field1 data-field2 ......
FOOTING
AT page-break-num SKIP 2 TAB 01 "Footing Line"
FOOTING AT key-field P-BACK
I hope this is helpful. If anyone has any other suggestions, they
would be appreciated.
Carol
(PH 7.29.C8 / MPE/ix 5.5)