Solved

Delphi 7 :: Rave Report - Several Reports Print in ONE spool JOB

Posted on 2007-12-05
7
6,026 Views
Last Modified: 2013-11-23
Dear Experts,

I am using Delphi 7 and Rave Reports.
I have a procedure which loops through a dataset and according to my parameters
prints reports.
How can I change my code to rather loop through the dataset and add all the reports, somewhere???, and after the loop I would like to do ONE print execute which will then print all added reports in one spool job.

I have looked at the nevrona tip at: http://www.nevrona.com/Default.aspx?tabid=117
but it is not clear enough to me. Because for each report I am setting some params as well.

Anyone that can please explain this to me in detail?


Please see my current code attached....

Thanks in advance.
function TfrmMain.PrintStillageLabel(const ABarCode :String): Boolean;
begin
  Try
 
    //Print the stillage labels if AutoPrintSL is flagged on
    qStillages.SQL.Text := 'SELECT S.BarCode, S.POrderNumber, S.Sequence, S.TheirDateTime, S.ItemDescription, '+
      'S.PartTypeNumber, P.StillageQty, P.PrintBOMSL ' +
      'FROM tblStillages S LEFT OUTER JOIN tblPartTypes P ON S.PartTypeNumber = P.PartTypeNumber '+
      'WHERE (BarCode = :BarCode) AND (S.SLPrinted = 0) AND (P.AutoPrintSL = 1) '+
      'ORDER BY TheirDateTime, Sequence';
    qStillages.Parameters.ParamByName('BarCode').Value := ABarCode;
    qStillages.Open; qStillages.Last; qStillages.First;
    If qStillages.IsEmpty then Exit;
 
    rvSystem.DefaultDest := rdPrinter;
    rvSystem.SystemSetups := rvSystem.SystemSetups - [ssAllowSetup];
 
    rvProject.Open;
    rvProject.SelectReport('repStillageLabel', False);
    rvProject.SetParam('Date', DateToStr(Date));
    rvProject.SetParam('Time', TimeToStr(Time));
    rvProject.SetParam('PartType', qStillages.FieldByName('PartTypeNumber').AsString);
    rvProject.SetParam('StillageQty', qStillages.FieldByName('StillageQty').AsString);
    rvProject.SetParam('BarCode', qStillages.FieldByName('BarCode').AsString);
    rvProject.Execute;
 
    //Mark this SL as printed.
    qUpdate.SQL.Text := 'UPDATE tblStillages SET SLPrinted = 1 WHERE BarCode = :BarCode';
    qUpdate.Parameters.ParamByName('BarCode').Value := ABarCode;
    qUpdate.ExecSQL;
 
    WriteToLog(logAttention, 'Stillage Label Printed: ' + ABarCode);
  Except
    On E:Exception do
    begin
      Result := False;
      WriteToLog(logError, E.Message);
    end;
  end;
end;

Open in new window

0
Comment
Question by:Marius0188
  • 5
  • 2
7 Comments
 

Author Comment

by:Marius0188
ID: 20410698
Also note that it is the same report that I print, just with different field values.
Thanks.
0
 

Author Comment

by:Marius0188
ID: 20410700
and different report parameters.
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 500 total points
ID: 20411097
 According to Nevrona you need to print your separate reports from within the rvSystem.OnPrint event.  To print all of the reports call rvSystem.Execute.

  Here is a small example I did.  I pointed an rvProject to a project of mine via the object inspector and set it's system property to an rvSystem component.  I filled in the rvSystems OnPrint event and put a button on the form and responded to the OnClick event.  Here's the code.


unit Unit2;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RpBase, RpSystem, RpDefine, RpRave, rvLdCompiler, RvDLADO;
 
type
  TForm2 = class(TForm)
    RvProject1: TRvProject;
    RvSystem1: TRvSystem;
    Button1: TButton;
    procedure RvSystem1Print(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form2: TForm2;
 
implementation
 
{$R *.dfm}
 
procedure TForm2.Button1Click(Sender: TObject);
begin
  RvSystem1.Execute;
end;
 
procedure TForm2.RvSystem1Print(Sender: TObject);
begin
  //print two
  with sender as TBaseReport do
    begin
      rvProject1.Open;
      rvProject1.SelectReport('WarehouseActivityReport', true);
 
      rvProject1.SetParam('Warehouse', 'CS-SHOE');
      rvProject1.ExecuteReport('WarehouseActivityReport');
      NewPage;
 
      rvProject1.SetParam('Warehouse', 'CS-AGGIND');
      rvProject1.ExecuteReport('WarehouseActivityReport');
      //NewPage; //if printing another report
    end;
end;
 
end.

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Marius0188
ID: 20418428
Ok what I have done, was to call the rvSystem.Execute method in the in the OnPrint() I ran my code which check what should be printed or not. Just, or nearly, like nevrona's example.

But the problem is I get blank pages printed.
In the OnPrint() event's code I have a condition and when true then it should print but it prints for each loop whether condition true or not. Is this normal?

Check my OnPrint() code:
procedure TfrmMain.rvSystemPrint(Sender: TObject);
var
  X :Integer;
begin
  For X := 0 to slStillagePrintList.Count - 1 do
  begin
    Try
      //Print the stillage labels if AutoPrintSL is flagged on
      qStillages.SQL.Text := 'SELECT S.BarCode, S.POrderNumber, S.Sequence, S.TheirDateTime, S.ItemNumber, S.ItemDescription, '+
        'S.PartTypeNumber, P.StillageQty, P.PrintBOMSL ' +
        'FROM tblStillages S LEFT OUTER JOIN tblPartTypes P ON S.PartTypeNumber = P.PartTypeNumber '+
        'WHERE (BarCode = :BarCode) AND (S.SLPrinted = 0) AND (P.AutoPrintSL = 1) '+
        'ORDER BY TheirDateTime, Sequence';
      qStillages.Parameters.ParamByName('BarCode').Value := Trim(slStillagePrintList.Strings[X]);
      qStillages.Open; qStillages.Last; qStillages.First;
      If not qStillages.IsEmpty then
      begin
        qStillageBoms.Open;
        
        rvSystem.DefaultDest := rdPrinter;
        rvSystem.SystemSetups := rvSystem.SystemSetups - [ssAllowSetup];
 
        rvProject.Open;
        rvProject.SelectReport('repStillageLabel', False);
        rvProject.SetParam('Date', DateToStr(Date));
        rvProject.SetParam('Time', TimeToStr(Time));
        rvProject.SetParam('PartType', qStillages.FieldByName('PartTypeNumber').AsString);
        rvProject.SetParam('StillageQty', qStillages.FieldByName('StillageQty').AsString);
        rvProject.SetParam('BarCode', qStillages.FieldByName('BarCode').AsString);
        rvProject.Execute;
 
        //Mark this SL as printed.
        qUpdate.SQL.Text := 'UPDATE tblStillages SET SLPrinted = 1 WHERE BarCode = :BarCode';
        qUpdate.Parameters.ParamByName('BarCode').Value := slStillagePrintList.Strings[X];
        qUpdate.ExecSQL;
 
        WriteToLog(logAttention, 'Stillage Label Printed: ' + slStillagePrintList.Strings[X]);
 
        If X <> slStillagePrintList.Count - 1 then TBaseReport(Sender).NewPage;
      end;
      lsbPrinter.Selected[X] := True;
    Except
      On E:Exception do
      begin
        WriteToLog(logError, E.Message);
      end;
    end;
  end;
end;

Open in new window

0
 

Author Comment

by:Marius0188
ID: 20418474
Let me put it a little clearer.

I am doing as nevrona says. Do my printing in the OnPrint() event.
But I have procedure outside from the event which does some processing and when finished it calls the
rvSystem.Execute method.

But the problem is, not every call to rvSystem.Execute will have printable information. Therefore the condition see: Line 16 in code snippet above....
Printing should only occur when there are results in the dataset. But what currently happens is when the result is empty then it prints a blank page. Why this? All the code that relevant to printing is inside this If condition.

Please help.
0
 

Author Comment

by:Marius0188
ID: 20418707
Hi,

The problem is not my code, I believe.

I have build a demo application, with a TrvSystem and TrvProject component which are linked.
Added a TButton on the form.
The buttons OnClick() event has the following code:
   rvSystem1.Execute.

I have assigned the Rave Report project to the TrvProject.ProjectFile and have click StoreRav.

No code exists in the rvSystem1.OnPrint() event.
But when clicking button then a blank pages prints.

Why so?


Help?
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 20442351
 Normally when I get blank pages the dataset is returning no records...  That can be due to not setting parameters or other issues.  It depends on what type of datasets you are using in Rave too.  First just create 3 form style reports that require no data.  All you have to do is put a shape, text box, etc on the report and save it.  Then, run your code calling those reports (so they print in one job).  This should work with no problems and indicate that there is nothing  wrong with your code.  You then need to figure out why your report has no records.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Internet Explorer View Settings Question 15 111
FMX and jaudiotracker playing memory stream 29 79
CheckListBox usage 3 59
RESTRequest Parameter 4 30
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question