Page 1 of 1

Batch printing - prepared report

Posted: Tue Oct 28, 2014 4:59 pm
by dmajkic
In FR documentation there is a neat feature which enables FR to print multiple documents in one go. Like this:
 
frxReport1.LoadFromFile('Invoice.fr3');
frxReport1.PrepareReport;
frxReport1.LoadFromFile('StorageOrder.fr3');
frxReport1.PrepareReport(False);
frxReport1.ShowPreparedReport;

The idea is to print Invoice, Storage order (...) in one go.
There is FRX support for PrepareReport(), but I always get first report.
Is this supported? Example?
--
Dusan Majkic
Wings Software

Batch printing - prepared report

Posted: Wed Oct 29, 2014 9:40 am
by ignacio
dmajkic escribió el mar, 28 octubre 2014 16:59
In FR documentation there is a neat feature which enables FR to print multiple documents in one go. Like this:
 
frxReport1.LoadFromFile('Invoice.fr3');
frxReport1.PrepareReport;
frxReport1.LoadFromFile('StorageOrder.fr3');
frxReport1.PrepareReport(False);
frxReport1.ShowPreparedReport;

The idea is to print Invoice, Storage order (...) in one go.
There is FRX support for PrepareReport(), but I always get first report.
Is this supported? Example?
--
Dusan Majkic
Wings Software

Yes is supported. The example would almost like your, just change the dot with double dot.
Regards,

Re: Batch printing - prepared report

Posted: Fri Dec 02, 2016 4:38 pm
by dmajkic
Tried this again, but it is not working. I do this:

Code: Select all

// First Invoice
frxReport1:LoadFromFile('Invoice.fr3')
frxReport1:AddDbf( "INVOICE", {"INVOICE->*"} )
frxReport1:PrepareReport()

// Second Invoice (code is not there, invoice data is different )
frxReport1:LoadFromFile('Invoice.fr3')
frxReport1:AddDbf( "INVOICE", {"INVOICE->*"} )
frxReport1:PrepareReport(.T.)

frxReport1:ShowReport(.T.)


But the data on both invoices are from first report. Like the new AddDbf() is not replacing data.
Setting variables to new values do work.

Re: Batch printing - prepared report

Posted: Wed Dec 07, 2016 12:50 pm
by ignacio
Please try calling TFastReport:ForceReload() before calling AddDbf() the second time. Something like this:

Code: Select all

WITH OBJECT ::oFrx
  SET FILTER TO ...
  GO TOP
  :AddDbf("biolife", "biolife->*" )
  :PrepareReport(.F.)
  SET FILTER TO ...
  GO TOP
  :ForceReload()
  :AddDbf("biolife", "biolife->*" )
  :PrepareReport(.T.)
  :ShowPreparedReport()
END WITH


Regards,

Re: Batch printing - prepared report

Posted: Thu Dec 08, 2016 12:33 am
by dmajkic
Thank you Ignacio for your fast response!

With ForceReload I have distinct data, but variables are gone.

Please find minimal example attached. You can build it with "hbmk2 b.hbp". Set your licence and copy latest frx.dll in folder.
frx_test_multireport.zip
(51.36 KiB) Downloaded 77 times

Re: Batch printing - prepared report

Posted: Thu Dec 08, 2016 4:11 am
by nbatocanin
This program works:

Code: Select all

oFr:Create()

Art->a_name := "Field 1111"
oFr:LoadFromFile ("report.fr3")
oFr:AddDbf ("ART", {"ART->*"})
oFr:PrepareReport(.F.)

Art->a_name := "Field 2222"
oFr:LoadFromFile ("report.fr3")
oFr:AddDbf ("ART", {"ART->*"})
oFr:PrepareReport(.T.)

oFr:ShowReport (.T.)


Report writes:

P1: Field 1111
P2: Field 2222

But this does not work:

Code: Select all

oFr:Create()

Art->a_name := "This is 1111"
oFr:LoadFromFile ("report.fr3")
oFr:AddDbf ("ART", {"ART->*"})
oFr:AddVariable ("VAR", "X", 1)        //  1
oFr:PrepareReport(.F.)

Art->a_name := "This is 2222"
oFr:LoadFromFile ("report.fr3")
oFr:AddDbf ("ART", {"ART->*"})
oFr:AddVariable ("VAR", "X", 2)      // 2
oFr:PrepareReport(.T.)

oFr:ShowReport (.T.)


Pages:

P1: Field 1111 x = 1
P2: Field 1111 x = 2

When I im change order to:

oFr:LoadFromFile ("report.fr3")
oFr:AddVariable ("VAR", "X", 1) // 1
oFr:AddDbf ("ART", {"ART->*"})

Then report does not see variable X.

Re: Batch printing - prepared report

Posted: Fri Dec 09, 2016 11:33 am
by ignacio
Hello,

Here is working fine! See report attached.

BTW, I have just upload the latest version of FRX for console mode on our download area:

http://www.xailer.com/download?en&file=103

Regards,

Re: Batch printing - prepared report

Posted: Fri Dec 09, 2016 3:47 pm
by nbatocanin
After new version instalation:

Error BASE/1082 Argument error: -
Called from TFRARRAYDATASET:LOAD(549)
Called from FRAPP:LOADDATA(400)
Called from FRAPP:LOADREPORT(486)
Called from FRAPP:LOADFROMFILE(661)
Called from FR_REPORT(582)

Re: Batch printing - prepared report

Posted: Fri Dec 09, 2016 4:27 pm
by ignacio
Hello,

Array can not be empty. BTW, run time error controlled for next release.

Regards,

Re: Batch printing - prepared report

Posted: Fri Dec 09, 2016 6:21 pm
by nbatocanin
ignacio wrote:Hello,

Array can not be empty. BTW, run time error controlled for next release.

Regards,


I use the older version (1.5.1411.27) and it accepts empty arrays (= DBF tables without records) without any problems. It is impossible for me to change the all program/reports and looking for all the places where they appear empty arrays. Is there a some solution at the FastReport level? I think that some run time error control handler is not a good solution.

Re: Batch printing - prepared report

Posted: Mon Dec 19, 2016 1:23 am
by nbatocanin
Sorry to bother you, but this is very important to me.

Is there any chance of returning to the old way of working with empty arrays? Older versions accepts empty arrays and not report an error when this happens.

Regards, NB

Re: Batch printing - prepared report

Posted: Mon Dec 19, 2016 10:52 am
by ignacio
Hello,

Sorry, your message has been unintentionally forgotten.

I hope you can include a simple line in the source code of FrDataset.prg. In case not I will upload a new version. Here is the code:

Code: Select all

METHOD Load( lDesign )  CLASS XFrArrayDataset
   .....
   .....
   .....
   oRep   := ::oReport
   nPos   := 1   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NEW LINE
   aData  := ::aData
   .....
   .....
   .....
RETURN .T.


Regards

Re: Batch printing - prepared report

Posted: Tue Dec 20, 2016 2:35 am
by nbatocanin
I found FrDataset.prg, but do not know how to include this PRG into my program?

Regards, NB


ignacio wrote:Hello,

Sorry, your message has been unintentionally forgotten.

I hope you can include a simple line in the source code of FrDataset.prg. In case not I will upload a new version. Here is the code:

Code: Select all

METHOD Load( lDesign )  CLASS XFrArrayDataset
   .....
   .....
   .....
   oRep   := ::oReport
   nPos   := 1   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NEW LINE
   aData  := ::aData
   .....
   .....
   .....
RETURN .T.


Regards

Re: Batch printing - prepared report

Posted: Tue Dec 20, 2016 10:03 am
by ignacio
New install file: https://dl.dropboxusercontent.com/u/31888702/Xailer/frx15.exe

Please confirm it works as expected. TIA.

Re: Batch printing - prepared report

Posted: Tue Dec 20, 2016 3:24 pm
by nbatocanin
Unfortunately, there is still a problem. Pleas look this test program:

Code: Select all

PROC Main
      USE Art NEW EXCLUSIVE

      oFr := frReportManager():New()
      oFr:cFRLicense := ...
      oFr:cXALicense := ...

   Art->a_name := "This is 1111"
      oFR:Create()
   oFr:LoadFromFile ("report.fr3")
   oFr:AddDbf ("ART", {"ART->*"})
   oFr:AddVariable ("VAR", "X", 1)

   oFr:DesignReport()
   oFr:ShowReport (.T.)
RETURN


This program work perfect with old version. In new version, designer does not see variable X!

One more thing: please add "instalation dir" in instalation procedure. Now you can not even see where the program is installed. Also, without question FRX is install on the old path and overwrite the old version with no questions asked.

Regards, NB

ignacio wrote:New install file: https://dl.dropboxusercontent.com/u/31888702/Xailer/frx15.exe

Please confirm it works as expected. TIA.

Re: Batch printing - prepared report

Posted: Tue Dec 20, 2016 4:34 pm
by ignacio
Hello,

Review FUNCTION Sergey() on module FRConsole.prg (line 364). Here is working fine.

Regards,

Re: Batch printing - prepared report

Posted: Wed Dec 21, 2016 4:35 pm
by nbatocanin
ignacio wrote:Hello,

Review FUNCTION Sergey() on module FRConsole.prg (line 364). Here is working fine.

Regards,


Sorry, I do not understand? Line 364 is:

:AddVariable( "Categoria", "Nombre", 123 )

I use:

oFr:AddVariable ("VAR", "X", 1)

This is the same? I rewrote the program so it does not use the Sergey-specific commands (I think). Can you tell me exactly which command is the problem?

Re: Batch printing - prepared report

Posted: Wed Dec 21, 2016 8:19 pm
by ignacio

Re: Batch printing - prepared report

Posted: Thu Dec 22, 2016 3:28 am
by nbatocanin
Sorry, I still do not understand?


Re: Batch printing - prepared report

Posted: Thu Dec 22, 2016 1:08 pm
by ignacio
From the link given:

Another new operator - WITH OBJECT:

Code: Select all

      WITH OBJECT expression
         ...
      ENDWITH

It allows to simplify the code for the reasonable use :

Code: Select all

      // you can write
      WITH OBJECT myobj:a[1]:myitem
         :message( 1 )
         :value := 9
      ENDWITH

      // instead of
      myobj:a[1]:myitem:message( 1 )
      myobj:a[1]:myitem:value := 9

Re: Batch printing - prepared report

Posted: Thu Dec 22, 2016 8:15 pm
by nbatocanin
Ok, but I do not see the connection with this problem? This program with the new version does not work properly.

Code: Select all

PROC Main
   USE Art NEW EXCLUSIVE

   oFr := frReportManager():New()
   oFr:cFRLicense := ...
   oFr:cXALicense := ...
   
   Art->a_name := "This is 1111"
   oFR:Create()
   oFr:LoadFromFile ("report.fr3")
   oFr:AddDbf ("ART", {"ART->*"})
   oFr:AddVariable ("VAR", "X", 1)

   oFr:DesignReport()
   oFr:ShowReport (.T.)
RETURN


Why? This is a very simple program and I do not see why it does not work properly?

Regards, NB

ignacio wrote:From the link given:

Another new operator - WITH OBJECT:

Code: Select all

      WITH OBJECT expression
         ...
      ENDWITH

It allows to simplify the code for the reasonable use :

Code: Select all

      // you can write
      WITH OBJECT myobj:a[1]:myitem
         :message( 1 )
         :value := 9
      ENDWITH

      // instead of
      myobj:a[1]:myitem:message( 1 )
      myobj:a[1]:myitem:value := 9

Re: Batch printing - prepared report

Posted: Wed May 10, 2017 11:03 am
by anser
Is there any solution for this problem ?

I too have the same issue. The variables added from PRG does not appear in the FastReport

oFr:AddVariable ("VAR", "X", 1)