| Writing the Genero BDL report program / Fetching report data | |
You can get the report data from a data file - one created by the BDL UNLOAD statement, for example.
This example uses the OrderReport.unl file in the GRW demo Reports.
MAIN
DEFINE handler om.SaxDocumentHandler -- report handler
--call the mandatory functions that configure the report
IF fgl_report_loadCurrentSettings("myreport.4rp") THEN -- if the file
-- loaded OK
LET handler = fgl_report_commitCurrentSettings() -- commit the file
-- settings
ELSE
EXIT PROGRAM
END IF
-- run the report by calling the report driver contained in your
-- function runReportFromFile
IF handler IS NOT NULL THEN
CALL runReportFromFile(handler)
END IF
END MAIN
The function runReportFromFile replaces the runReportFromDatabase function as the Report Driver. It uses the unload file OrderReport.unl to provide the data for the report.
FUNCTION runReportFromFile(handler)
DEFINE
orderline OrderType,
handler om.SaxDocumentHandler,
ch base.channel, -- definition of channel object
dataFile String -- file containing report data
LET dataFile = "./OrderReport.unl"
LET ch = base.Channel.create()
CALL ch.openFile(dataFile,"r")
START REPORT report_all_orders TO XML HANDLER handler
WHILE ch.read([orderline.*])
OUTPUT TO REPORT report_all_orders(orderline.*)
END WHILE
FINISH REPORT report_all_orders
CALL ch.close()
END FUNCTION