[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: SQR last Page problem



Terry,

Just for an odd-ball approach, why not just put the output from SQRs A & B into a table, (Col A RPT/Line#, Col B Text string), then run a SQR C to determine how many pages are in the report and then print those pages?

Bob

>>> "Cheung, Terry, BMG Oldbury" <Terry.Cheung@BMG.CO.UK> 11/16 12:15 PM >>>
Hi,

Thanks for the reply. Unfortunately the suggested solutions did not quite
resolve the problem - that's because the actual problem is more complicated
than explained.


I have two different report types/layouts in a single document (say report A
and report B) -
I need to have "Page <current-number>/<last-page>" on every page  where
<current-page> needs to be a single set of continuous page numbers across
two reports and  <last-page> = (total pages of report A + total pages of
report B)

i.e.
The logical page order of this single document would be for example:

report A:Page1/5
report A:Page2/5
report A:Page3/5
report B:Page4/5
report B:Page5/5

Currently SQR generates two files one for reportA and reportB. I am printing
reportA then reportB in that order.

let me show you the simplified version of the current code:
############################################################
begin-program
do main_report_A
end-program

begin-procedure main_report_A
 use-report A
 begin-select
 :
 :
     if page is full
          new-page
     end-if
      if select data row conditions is true
         do main_report_B(parameters from select statement of A)
      else don't print report B for that row
      end-if
 from table A
end-procedure

begin-procedure main_report_B
 use-report B
 begin-select
 :
 :
   if page is full
       new-page
   end-if
 from table B
where columns = parameters of A
end-procedure

begin-heading
  if called from report A
      print header A
      print <current page>
      print <last page>
  end-if
   if called from report B
      print header B
       print <current page>
       print <last page>
   end if
end-heading
################################################################
I used the suggestion of setting #page-count this gives me the correct
<last-page>.

If I run the current code (above) and the setting of #page-count this would
give me the correct <last-page> and the correct <current-page> on report A.
The problem I have is setting the correct <current-page> on reportB.

Now the easy way is to run report A entirely first (thus giving me the total
page number for report A) and then run report B incrementing the last page
number of report A to get the current page. This could be done by storing
all parameters (for report B)into an array during the select statement of
report A. Unfortunately  I need to have dynamic array to capture the report
A parameters as I don't know the size of array until during runtime and SQR
don't support dynamic array and also it would not be practical to allocate a
maximum size of static array.

The alternative is to try to insert a eg @@ where <current-page> is for
report B and then using UNIX system commands (sed) to replace @@ with the
actual number after report A have completed, but unfortunately where do I
call the "call system using" to invoke the sed command ? How do I get the
output file from the UNIX sed command to become the output file generated by
SQR?

I would be grateful if any SQR experts out here to provide some insights or
suggestions and put this nightmare to a rest!!!

Terry Cheung - Bertelsmann mediaSystems
BMG Distribution, Unit 24 Crystal Drive, Warley, West Midlands, B66 1QG,
United Kingdom.
* terry.cheung@bmg.co.uk 
* terry.cheung@bertelsmann.de 
* Tel: +(44)-121-543-4276