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.
LET grw_handler = fgl_report_createProcessLevelDataFile("FILE1")
START REPORT report1 TO XML HANDLER grw_handler
FOR I = 1 to 10
OUTPUT TO REPORT report1(i)
END FOR
FINISH REPORT report1
LET grw_handler2 = fgl_report_createProcessLevelDataFile("FILE2")
START REPORT report2 TO XML HANDLER grw_handler2
FOR I = 1 to 10
OUTPUT TO REPORT report2(i)
END FOR
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:
#First generate the process level data file called "FILE1"
LET grw_handler = fgl_report_createProcessLevelDataFile("FILE1")
START REPORT report1 TO XML HANDLER grw_handler
FOR I = 1 to 10
OUTPUT TO REPORT report1(i)
END FOR
FINISH REPORT report1
#Show the report using "invoice.4rp" for SVG viewing.
IF NOT fgl_report_loadCurrentSettings("invoice.4rp") THEN
RETURN FALSE
END IF
LET grw_handler=fgl_report_commitCurrentSettings()
IF NOT fgl_report_runReportFromProcessLevelDataFile(grw_handler,"FILE1") THEN
RETURN FALSE
END IF
#Create a PDF copy for archiving using the design "archiving_invoice.4rp".
IF NOT fgl_report_loadCurrentSettings("archiving_invoice.4rp") THEN
RETURN FALSE
END IF
CALL fgl_report_selectDevice("PDF")
CALL fgl_report_configureOutputFileName("invoice"||invoiceNumber||".pdf")
LET grw_handler=fgl_report_commitCurrentSettings()
IF NOT fgl_report_runReportFromProcessLevelDataFile(grw_handler,"FILE1") THEN
RETURN FALSE
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:
#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"
IF NOT fgl_report_loadCurrentSettings("invoice.4rp") THEN
RETURN FALSE
END IF
CALL fgl_report_setProcessLevelDataFile("FILE1")
LET grw_handler=fgl_report_commitCurrentSettings()
START REPORT report1 TO XML HANDLER grw_handler
FOR I = 1 to 10
OUTPUT TO REPORT report1(i)
END FOR
#Create a PDF copy for archiving using the design "archiving_invoice.4rp".
IF NOT fgl_report_loadCurrentSettings("archiving_invoice.4rp") THEN
RETURN FALSE
END IF
CALL fgl_report_selectDevice("PDF")
CALL fgl_report_configureOutputFileName("invoice"||invoiceNumber||".pdf")
LET grw_handler=fgl_report_commitCurrentSettings()
IF NOT fgl_report_runReportFromProcessLevelDataFile(grw_handler,"FILE1") THEN
RETURN FALSE
END IF
Regards,
Alex