1 / 76

IBM Informix Genero Genero Report Writer

IBM Informix Genero Genero Report Writer. <<Speaker Name Here>> <<For questions about this presentation contact Speaker Name speaker@us.ibm.com>>. Genero Report Writer (GRW) - Overview GRW Architecture File Extensions Report Process Components of a Genero Report Code Example

jbolduc
Download Presentation

IBM Informix Genero Genero Report Writer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IBM Informix GeneroGenero Report Writer <<Speaker Name Here>> <<For questions about this presentation contact Speaker Name speaker@us.ibm.com>>

  2. Genero Report Writer (GRW) - Overview GRW Architecture File Extensions Report Process Components of a Genero Report Code Example Required Library Minimally required changes to a 4GL report GRW functions / Library Report Output and XML Appendix Agenda

  3. Genero Report Writer (GRW) - Overview Streams data from Genero DVM for "print-as-you-go" processing: No temporary files or tables required (less memory, more speed) Gathering of data separate from layout. Based on XML standards. Report layout defined in a separate document using Report Designer. Multiple layouts can be designed for a single data stream. Introduction to Genero Report Writer 3

  4. GRW Features Enterprise Reports Highly Scalable Streaming architecture Drag-and-drop GUI report design Dynamic layout capability Easy and Simple to Maintain Introduction to Genero Report Writer 4

  5. Architecture XML Standards DataStream is xml Report Design file (.4rp) is xml SVG output (.svg) is xml Gathering of data is separate from layout. Same data can be used to print many different reports in different formats. End to end streaming, print as you go: Note: Internals of the PDF format do not support end to end streaming. Introduction to Genero Report Writer 5

  6. Architecture Introduction to Genero Report Writer 6

  7. Architecture Genero BDL to produce XML DataStream via REPORT Uses 4gl features including the REPORT statement to produce XML data stream Introduction to Genero Report Writer 7

  8. Architecture Genero Report Designer (GRD) design a report Near WYSIWYG editor to design the appearance of a report Introduction to Genero Report Writer 8

  9. Architecture Genero Report Engine uses these two inputs to produce a formatted report (SVG, PDF, or Image): XML DataStream + Report Design = Formatted Output. The Layouter does the Layouting. Calculates where to position objects, and how to render them: GRE typically runs on a server, similar to application or database server. Introduction to Genero Report Writer 9

  10. Architecture Viewing occurs on end-users client , similar to GDC: Genero Report Viewer (GRV) to view SVG reports. Adobe for PDF reports. Any image viewer for Image reports. As images, these can be embedded directly into a Genero application. Introduction to Genero Report Writer 10

  11. Architecture Report Data Definition (RDD) When designing reports, need to inform the report designer about what information will be available in the report. rddfile Introduction to Genero Report Writer 11

  12. File Extensions .4gl Genero 4gl source file. .rdd Definition of data and structure of REPORT statements in .4gl source. Used by Genero Report Designer in design of reports. .xml DataStream produced by REPORT statement. Allows you to repeatedly test reports without selecting data from the database multiple times. .4rp Design of a report. .svg, .pdf, (.jpg, .png, .bmp and others) Different output formats of a report Introduction to Genero Report Writer 12

  13. Report Process Determine report requirements. Organize the project workspace. Create the Genero report application: Written in Genero BDL. Report Data wizard provided. Generate the .rdd file: Use fglcomp Provides the Data View for a report. Design report design document using Genero Report Designer. Run the report application. View the report using Genero Report Viewer. Introduction to Genero Report Writer 13

  14. Components of a simple 4GL report Report driver: Specifies the data the report will include. Report program block: Specifies the control blocks for a report. Sends the data to the Genero Report Engine. Type definition (record of values). Mandatory Reporting API functions. Creating the Report Application 14

  15. Code Example MAIN DEFINE handler om.SaxDocumentHandler DATABASE "custdemo" If fgl_report_loadCurrentSettings("reportname.4rp") THEN LET handler = fgl_report_commitCurrentSettings() ELSE EXIT PROGRAM END IF IF handler IS NOT NULL THEN CALL run_storeorder_to_handler(handler) END IF END MAIN Creating the Report Application 15

  16. Code Example - Report Driver FUNCTION run_storeorder_to_handler(handler) DEFINE data storeorder_data, handler om.SaxDocumentHandler DECLARE cur CURSOR FOR SELECT orders.*, items.*, state.*, factory.*, customer.*, stock.* FROM orders, items, state, factory, customer, stock WHERE customer.store_num = orders.store_num AND orders.order_num = items.order_num AND items.stock_num = stock.stock_num AND orders.fac_code = stock.fac_code AND stock.fac_code = factory.fac_code AND customer.state = state.state_code ORDER BY customer.store_num, orders.order_num ... Creating the Report Application 16

  17. Code Example - Type definition Creating a TYPE allows the record definition to be specified only once in the program The name of the TYPE is then used in the program wherever the record definition is required SCHEMA custdemo TYPE storeorder_data RECORD orders RECORD LIKE orders.*, items RECORD LIKE items.*, state RECORD LIKE state.*, factory RECORD LIKE factory.*, customer RECORD LIKE customer.*, stock RECORD LIKE stock.* END RECORD Creating the Report Application 17

  18. Code Example - Report Driver ... START REPORT storeorder_report TO XML HANDLER handler FOREACH cur INTO data.* OUTPUT TO REPORT storeorder_report(data.*) END FOREACH FINISH REPORT storeorder_report CLOSE cur END FUNCTION Creating the Report Application 18

  19. Code Example - Report definition block REPORT storeorder_report(data) DEFINE data storeorder_data ORDER EXTERNAL BY data.customer.store_num, data.orders.order_num FORMAT ON EVERY ROW PRINT data.* END REPORT Creating the Report Application 19

  20. Minimally required changes to a 4GL report DEFINE <handler variable> om.SaxDocumentHandler CALL fgl_report_loadCurrentSettings(<.4rp file>) RETURNING Boolean CALL fgl_report_selectDevice([Printer|PDF|SVG|Image]) CALL fgl_report_selectPreview([TRUE|FALSE]) CALL fgl_report_setOutputFileName(<file>) LET <handler variable> = fgl_report_commitCurrentSettings() START REPORT <report> TO XML HANDLER <handler variable> Creating the Report Application 20

  21. GRW functions / Library Mandatory fgl_report_loadCurrentSettings(.4rp_file) Sets report settings according to .4rp file Returns OK (Boolean) fgl_report_commitCurrentSettings() Configures report engine Returns om.SaxDocumentHandler (XML handler) IF fgl_report_loadCurrentSettings(r_filename) THEN LET handler = fgl_report_commitCurrentSettings() ELSE EXIT PROGRAM END IF Creating the Report Application 21

  22. fgl_report_loadCurrentSettings() Layout the report using the selected .4rp report file. Includes defaults for settings such as paper size: Can be overridden by fgl_report_*() functions If NULL uses the ASCII layout implied by the REPORT statement. Mandatory to call this function before fgl_report_commitCurrent Settings() CALL fgl_report_loadCurrentSettings(<4rp file>) RETURNING boolean Creating the Report Application 22

  23. fgl_report_loadAndCommit() Available as a wrapper of fgl_report_loadCurrentSettings(<4rp file>) and fgl_report_commitCurrentSettings() Use if no other changes required between the load and the commit. CALL fgl_report_loadAndCommit(<4rp file>) RETURNING om.SaxDocumentHandler Creating the Report Application 23

  24. Changing output options fgl_report_loadCurrentSettings("report.4rp") loads settings from the report file. Can change report output options with additional fgl_report_* functions: Call prior to fgl_report_commitCurrentSettings() For now, we will look at: fgl_report_selectDevice() fgl_report_selectPreview() fgl_report_setOutputFilename() Creating the Report Application 24

  25. fgl_report_selectDevice() PDF – Creates a PDF document Either creates the .PDF file or opens the file in a PDF viewer, based on fgl_report_selectPreview(). Image – Creates one or more image files One image file per page. Printer – Sends report direct to default printer. Another function defines the printer. SVG - Creates an SVG document Either creates a .SVG file or opens the file in Genero Report Viewer, based on fgl_report_selectPreview(). CALL fgl_report_selectDevice("PDF") CALL fgl_report_selectDevice("Image") CALL fgl_report_selectDevice("Printer") CALL fgl_report_selectDevice("SVG") Creating the Report Application 25

  26. fgl_report_selectPreview() TRUE – report is Viewed in the appropriate viewer for the selected device. From there the user can choose: To print to a printer (File->Print) To save the file (File->Save) FALSE – report is either: Written to file(s). Sent to a printer if device selected is Printer. CALL fgl_report_selectPreview(TRUE) CALL fgl_report_selectPreview(FALSE) Creating the Report Application 26

  27. fgl_report_setoutputfilename() Only applies if preview is FALSE and device is notPRINTER If not specified, default file name is report.svg, report.pdf, or image0001.jpg. If device is Image, one file produced per page. Page number is appended to filename. e.g. Image0001.jpg, image0002.jpg CALL fgl_report_setOutputFilename("filename") Creating the Report Application 27

  28. Required Library - libgre.42x Must include library containing fgl_report_* functions Creating the Report Application 28

  29. Creating the RDD file From the command line: fglcomp --build-rdd <filename>.4gl From within Studio: Add --build-rdd to compiler options of the 4GL file containing the REPORT block. Creating the Report Application 29

  30. Output Report to Genero Report Writer “The SaxDocumentHandler class provides an interface to write an XML filter, following the SAX standards”. Various fgl_report_*() functions configure the behaviour of the XML filter. fgl_report_commitCurrentSettings() takes defined settings, passes them to the XML filter, and returns a pointer to the XML filter. REPORT instead of being sent to FILE, PIPE, PRINTER, or SCREEN, is instead turned into an XML document and processed by the XML filter (the Genero Reporting Engine). DEFINE <variable> om.SaxDocumentHandler -- Set settings with fgl_report_*() functions LET <variable> = fgl_report_commitCurrentSettings() START REPORT <report> TO XML HANDLER <variable> Creating the Report Application 30

  31. Report Output from a Data File IF handler IS NOT NULL THEN CALL runReportFromFile(handler) END IF 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 Creating the Report Application 31

  32. Using an intermediate XML datastream Does your existing application save reports for reprinting? What if you want to reprint in a different format? How long does it take to create the data? Hit the database only once. Each time you run the report do you have to reset configuration flags? Printed flags don’t have to be continually reset. Each time you run the report do you have to enter new data? Get all your test configurations into one XML datastream. Creating the Report Application 32

  33. XML data file best practices Create two applications The first application generates the XML data file. The second application uses the XML data file. Why? Hit the database ONCE. Repeatedly run the second application against the XML data file. Creating the Report Application 33

  34. Output Report to XML data file Instead of START REPORT creating an XML document and sending it to be configured by an XML filter, process stops after creating the XML file (the XML datastream). DEFINE handler om.SaxDocumentHandler LET handler = fgl_report_createProcessLevelDataFile(filename) START REPORT <report> TO XML HANDLER handler Creating the Report Application 34

  35. SCHEMA custdemo TYPE custstate RECORD ... MAIN DEFINE handler om.SaxDocumentHandler DATABASE "custdemo" CALL run_report(handler) END MAIN FUNCTION run_report(handler) DEFINE data custstate, handler om.SaxDocumentHandler DECLARE cur CURSOR FOR SELECT ... LET handler = fgl_report_createProcessLevelDataFile("testfile.xml") START REPORT report1_report TO XML HANDLER handler FOREACH cur INTO data.* OUTPUT TO REPORT report1_report(data.*) END FOREACH FINISH REPORT report1_report CLOSE cur END FUNCTION ... Example 4gl - Output to XML datastream Creating the Report Application 35

  36. Produce Report from XML data file The previously saved XML file is processed by the XML filter (the Genero Reporting Engine) Use the fgl_report_*() settings to configure output DEFINE <variable> om.SaxDocument.Handler -- Set settings with fgl_report_*() functions LET <variable> = fgl_report_commitCurrentSettings() CALL fgl_report_runReportFromProcessLevelDataFile( handler, filename) Creating the Report Application 36

  37. Example 4gl – Use XML datastream MAIN DEFINE xmlfile, reportfile, device STRING DEFINE preview BOOLEAN DEFINE result INTEGER DEFINE grw_handler om.SaxDocumentHandler LET xmlfile="testfile.xml" LET reportfile="rpt1.4rp" LET device="SVG" LET preview=TRUE IF fgl_report_loadCurrentSettings(reportfile) THEN CALL fgl_report_selectDevice(device) CALL fgl_report_selectPreview(preview) LET grw_handler = fgl_report_commitCurrentSettings() LET result = fgl_report_runReportFromProcessLevelDataFile(grw_handler,xmlfile) ELSE EXIT PROGRAM END IF END MAIN Creating the Report Application 37

  38. Appendix Creating the Report Application 39

  39. Genero Report Designer After this instruction, you will be able to: Create a report using Genero Report Designer. Associate a data schema (.rdd) with a report. Organize the structure of a report. Use the List Report template when creating a report. Creating a List Report 40

  40. Genero Report Designer (GRD) GRD is the default tool to edit .4rp files from within Genero Studio From the project view: double-click a .4rp right-click a .4rp and select Open .4rp report right-click an application, library, or virtual folder node and select New File >> Empty Report Right-click an application, library, or virtual folder node and select New File >> Templates >> (select from available templates) From the top-menu: File >> New >> Reports >> (select blank or from a template) File >> Open >> (select a .4rp file) Creating a List Report 41

  41. Genero Report Designer Main work area surrounded by dockable views. January 20 Creating a List Report 42

  42. GRD – Main Work Area Near WYSIWYG view of a report: Doesn’t repeat repeated detail items. Order is not necessarily page header, detail, page footer. Report objects can be selected, dragged, dropped in this view. January 20 Creating a List Report 43

  43. GRD - Data View Uses .rdd file to show What is coming from the 4gl The grouping structure (REPORT triggers) The variables (data objects) Drag and drop from here into main work space or report structure view: Default object type based on data type. January 20 Creating a List Report 44

  44. GRD - Data View Change Sample Data to improve preview. changes sort order of variables. changes default values given to variables when drag and dropped: width caption or value Name of variables can be improved by using (in 4gl) PRINTX name=<name> <variable> January 20 Creating a List Report 45

  45. GRD - Tool Box Drag and drop report objects onto report. Once report object is on report, you can alter the properties (including which data value is displayed). Tool Box organized into into logical groups. Frequently used objects at top. January 20 Creating a List Report 46

  46. GRD – Report Structure View Red dots (called report triggers) reflect structure of 4gl report control blocks. Branch nodes control how their child nodes are laid out. Report objects can be selected, dragged, dropped in the Report Structure. Reflects the XML structure of the .4rp file. January 20 Creating a List Report 47

  47. GRD - Properties View and edit the properties of the selected report item. Bold name indicates non-default value. Icons Select value using appropriate wizard. Reset to default value. Enter an expression. Groups are collapsible. January 20 Creating a List Report 48

  48. File >> Report Properties >> Paper Settings Specify the default paper settings. Used in design of report. Values can be overridden by 4gl function calls. Key feature: Note the standard list of page sizes. January 20 Creating a List Report 49

  49. File >> Report Properties >> Output Config... Specify the default output settings. Values can be overridden by 4gl function calls. With image Select type (e.g. jpg, bmp, png). Select resolution. January 20 Creating a List Report 50

More Related