Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Aborting a report with a JIT pipeline

edited September 2001 in General
I'm using a JITpipeline and running into troubles when I try to abort a
print job. The JIT pulls data from a tList. If the user selects a
different report as the current report is printing, I need to abort the
print job, reload the tist with the new data, and print the new report.
According to the help file, this should do the trick...

if MyReport.Printing then
begin
ppViewer1.Cancel;
MyReport.PageLimitReached;
MyReport.ResetDevices;
end;
MyList.Clear;
{Now start loading the MyList with the new data}

However, I run into all manor or errors when I do this. After the call to
PageLimitReached, the JIT's OnGetFieldValue is still called repeatedly. But
at that point, I've cleared out MyList and I'm reloading it with new data.
That causes AV's and range errors depending on what field RB happens to be
looking for.

It seems I need some sort of loop after the call to PageLimitReached to wait
for RB to wind down before I clear MyList and start a new process. How can
I tell when RB has truly finished calling the event handlers for the JIT
pipeline so that I can proceed? I tried all kinds of things like
Repeat...until (not MyReport.Printing) but that just caused a lockup.

Comments

  • edited September 2001
    Try something like this:

    TmyForm = class(TForm)
    ...
    procedure ppReport1BeforePrint(Sender: TObject);
    function ppJITPipeline1GetFieldValue(aFieldName: String): Variant;
    private
    FCancelling: Boolean;
    procedure CancelPrinting;
    end;

    implementation

    procedure TmyForm.ppReport1BeforePrint(Sender: TObject);
    begin
    FCancelling := False;
    end;

    procedure TmyForm.CancelPrinting;
    begin

    {Cancel Printing}
    FCancelling := True;

    end;

    function TmyForm.ppJITPipeline1GetFieldValue(aFieldName: String): Variant;
    begin

    if not(FCancelling) then
    begin
    ...
    end;

    end;

    FWIW

    Robert Leahey
    Thoughtsmithy
  • edited September 2001
    I've put blocks around the OnGetFieldValue event handler like this so that
    it doesn't do anything while I'm reloading the tList. I've even tried
    unasigning the event handlers. I've got three JITpipelines and the biggest
    problem is when I abort a print job that uses one pipeline and then load a
    report that uses one of the other pipelines.

    When the user selects a new report while one is printing to the ppViewer, I
    first call Report.PageLimitReached and then set the OnGetFieldValue of all
    three JITpipelines to nil. Then I load the tList for the new report. Just
    before the call to PrintToDevices, I set the OnGetFieldValue property for
    just the one JITpipeline that the new report uses.

    That should do the trick, but then something really weird happens. As the
    new report is printing, an error will occur in the OnGetFieldValue event
    handler for the pipeline from the previous report. The error is different
    each time depending on exactly when the previous report was aborted. So it
    may be a range error or an AV. The odd thing is that there's no reference
    to the event handler that generated the error. Even if the previous report
    is still printing, it shouldn't be calling that event handler since the
    event was assigned a nil value.
This discussion has been closed.