Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: GRW Limitation - 2 reports at the same time?  (Read 15596 times)
Paul M.
Posts: 31


« on: April 24, 2014, 01:07:01 pm »


Is this now impossible when using the report writer?

Code
  1. MAIN
  2.  
  3.  DEFINE i                        SMALLINT
  4.  DEFINE grw_handler              om.SaxDocumentHandler  
  5.  DEFINE grw_handler2             om.SaxDocumentHandler  
  6.  
  7.  LET grw_handler = fgl_report_createProcessLevelDataFile("FILE1")
  8.  START REPORT report1 TO XML HANDLER grw_handler
  9.  
  10.  LET grw_handler2 = fgl_report_createProcessLevelDataFile("FILE2")
  11.  START REPORT report2 TO XML HANDLER grw_handler2
  12.  
  13.  FOR I = 1 to 10
  14.      OUTPUT TO REPORT report1(i)
  15.      OUTPUT TO REPORT report2(i)
  16.  END FOR
  17.  
  18.  FINISH REPORT report1
  19.  FINISH REPORT report2
  20.  
  21. END MAIN                                

Everything ends up in FILE2. This is a very simple example.
I am currently changing existing ascii reports to use the GRW and in some case I do have reports starting at the same time that I need to send to xml as the reports are in the same for/foreach loop and using the same data but have very different outputs.

Do I now have to start rewriting code any time I need more that one report active at the same time?   
Alex G.
Four Js
Posts: 155


« Reply #1 on: April 24, 2014, 03:20:55 pm »

Hi Paul,
>Is this now impossible when using the report writer?

It is not possible to have two 4GL reports producing XML at the same time.
Perhaps the two reports cannot be combined into one larger report shipping the combined data of both.
If that isn't an option then the reports would have to be run in sequence as shown below.
 
Code
  1. LET grw_handler = fgl_report_createProcessLevelDataFile("FILE1")
  2. START REPORT report1 TO XML HANDLER grw_handler
  3.  
  4. FOR I = 1 to 10
  5.     OUTPUT TO REPORT report1(i)
  6. END FOR
  7.  
  8. FINISH REPORT report1
  9.  
  10. LET grw_handler2 = fgl_report_createProcessLevelDataFile("FILE2")
  11. START REPORT report2 TO XML HANDLER grw_handler2
  12.  
  13. FOR I = 1 to 10
  14.     OUTPUT TO REPORT report2(i)
  15. END FOR
  16.  
  17.  
  18. FINISH REPORT report2

>in some case I do have reports starting at the same time that I need to send to xml as the reports are in the same for/foreach loop and using the same data but have very different outputs.

For this case you would call fgl_report_createProcessLevelDataFile("FILE1") as you have done in your example and later when the file is complete you can call fgl_report_runReportFromProcessLevelDataFile(handler,"FILE1") any number of times with different outputs (e.g. PDF, SVG, ..) or even different designs.
Example:
Code
  1. #First generate the process level data file called "FILE1"
  2. LET grw_handler = fgl_report_createProcessLevelDataFile("FILE1")
  3.  
  4. START REPORT report1 TO XML HANDLER grw_handler
  5.  
  6. FOR I = 1 to 10
  7.     OUTPUT TO REPORT report1(i)
  8. END FOR
  9.  
  10. FINISH REPORT report1
  11.  
  12. #Show the report using "invoice.4rp" for SVG viewing.
  13. IF NOT fgl_report_loadCurrentSettings("invoice.4rp") THEN
  14.    RETURN FALSE
  15. END IF
  16. LET grw_handler=fgl_report_commitCurrentSettings()
  17.  
  18. IF NOT fgl_report_runReportFromProcessLevelDataFile(grw_handler,"FILE1") THEN
  19.    RETURN FALSE
  20. END IF
  21.  
  22. #Create a PDF copy for archiving using the design "archiving_invoice.4rp".
  23. IF NOT fgl_report_loadCurrentSettings("archiving_invoice.4rp") THEN
  24.    RETURN FALSE
  25. END IF
  26. CALL fgl_report_selectDevice("PDF")
  27. CALL fgl_report_configureOutputFileName("invoice"||invoiceNumber||".pdf")
  28. LET grw_handler=fgl_report_commitCurrentSettings()
  29. IF NOT fgl_report_runReportFromProcessLevelDataFile(grw_handler,"FILE1") THEN
  30.    RETURN FALSE
  31. END IF

There is also an alternative function "fgl_report_setProcessLevelDataFile(STRING fileName)" which creates the process level data file on the fly in addition to the regular output. This way you can for example have a report produce SVG output with can be viewed while the report is still running (In the previous example we had to wait for the report to complete creating the process level data file before we could view the first page) while producing the data file at the same time.
Example:
Code
  1. #First show the rendering of the design "invoice.4rp" in the "SVG viewer and at the same time record a process level data file called "FILE1"
  2. IF NOT fgl_report_loadCurrentSettings("invoice.4rp") THEN
  3.    RETURN FALSE
  4. END IF
  5. CALL fgl_report_setProcessLevelDataFile("FILE1")
  6. LET grw_handler=fgl_report_commitCurrentSettings()
  7.  
  8. START REPORT report1 TO XML HANDLER grw_handler
  9.  
  10. FOR I = 1 to 10
  11.     OUTPUT TO REPORT report1(i)
  12. END FOR
  13.  
  14. #Create a PDF copy for archiving using the design "archiving_invoice.4rp".
  15. IF NOT fgl_report_loadCurrentSettings("archiving_invoice.4rp") THEN
  16.    RETURN FALSE
  17. END IF
  18. CALL fgl_report_selectDevice("PDF")
  19. CALL fgl_report_configureOutputFileName("invoice"||invoiceNumber||".pdf")
  20. LET grw_handler=fgl_report_commitCurrentSettings()
  21. IF NOT fgl_report_runReportFromProcessLevelDataFile(grw_handler,"FILE1") THEN
  22.    RETURN FALSE
  23. END IF

Regards,
Alex
Paul M.
Posts: 31


« Reply #2 on: April 24, 2014, 03:40:46 pm »

Alex,

Thanks for your reply.
We produce the xml output and then let the user view/print it later at their convenience.

I was hoping that there was a simple workaround. If it were only two I would try and combine them but i have a lot more on my convert to-do list, so run in sequence it will have to be.

At least I know now.

Regards,

Paul Murray.

Alex G.
Four Js
Posts: 155


« Reply #3 on: April 24, 2014, 04:19:16 pm »

Hi Paul,
out of interest:
>We produce the xml output and then let the user view/print it later at their convenience.
Do you do that for all reports? Isn't latency an issue on larger reports using this approach?
Using the "fgl_report_setProcessLevelDataFile(STRING fileName)" function you could allow users to produce the first instance as a latency free document. When the document generation has completed then the process level data file is also ready for use.
This file could then be archived for later selection by users as you described so that the overall functionality would be similar.
Regards,
Alex
Paul M.
Posts: 31


« Reply #4 on: April 25, 2014, 02:26:19 pm »

Alex,

Yes, every report we produce are direct to a file and we have a program to list up a users reports and they can either view,delete or print them.
We have being doing it this way for about 20 years and its really never been an issue. Most want to see the final totals or summaries that appear at the end of the reports.

Regards,

Paul Murray.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines