- Overview
- Creating a report on a programmed data source
- Overview
- Creating a report on a programmed data source
- Programming the reading of records
- Order of execution of the different WLanguage events
Report based on a programmed data source
In a report on a programmed data source, the reading of the records that will be displayed in the report requires full programming in WLanguage. The data source can have any type (HFSQL file, query, text file, file from an external database, ...). The creation of a report based on a programmed data source is performed by the wizard for report creation. When the report based on a programmed data source is created, you can: - modify the data source of the report ("Data" tab in the report description).
- add or delete Item controls linked to the data source of the report.
| | |  | Important | Reports & Queries does not allow you to create reports based on a programmed data source. However, you have the ability to customize the reports on a programmed data source created in the standard report editor (color, fonts, size, ...). |
Creating a report on a programmed data source Overview Two steps are required to create a report based on a programmed data source: - Creating the report with the creation wizard.
- Programming the reading of records.
Creating a report on a programmed data source To create a report on a programmed data source: - Click
in the quick access buttons. - The creation window appears: click "Report" then "Report".
- The report creation wizard starts.
- Choose the layout of your report (table, form, label, ...). For more details, see The different types of reports.
- Select the data source of the report ("Other (programing, text file, memory area, HFSQL view)"). Then, select "I program the reading of my data source".
- For each type of report, specify the corresponding specific options.
| | Type of report | Specific options |
---|
Table report | - specify the number of columns found in the table.
- for each column, specify the caption and type of the printed value.
- modify (if necessary) the order of the different columns.
| Report on form | Form image, printing the form image, ... Options presented in detail in Report on form. | Label report | Format of labels, number of identical copies, ... Options presented in detail in Label report. |
- Specify the format of sheet on which the report will be printed. The report is printed in A4 format by default.
- Select the skin template of the report if necessary.
- Enter the name and title of the report. This name (".WDE". file corresponding to the report) will be used to identify the report in your programs.
- Validate the report creation.
- If the report contains a table, the report editor automatically proposes to change the format of the report and/or to reduce the size of the table if some of the table columns cannot be printed in the report.
- Specify (if necessary) the mode for reducing the report size:
- Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
- Use the landscape mode.
- Reduce the report size. Caution: according to the reduction percentage, the printed report may become unreadable.
- The report currently created is displayed in the report editor.
Programming the reading of records The programming required to read the records is presented in the following example: | | |  | Example | The information to print is in the HFSQL data file named "Customer". The data is displayed in the item controls. |
The following method is used to program the reading of records: - Reading the first record of the "Customer" data file in the event "Report opening" (HReadFirst).
// Read the first record of "Customer" data file HReadFirst(Customer, CustomerNum)
- The event "Reading data" of the report is used to manage the end of the data file. The following values are returned according to the case:
- True: end of file not reached (step 3 is run).
- False: end of file reached (step 3 is not run).
// End of "Customer" data file reached? IF HOut() = True THEN // Stop printing the Body block RESULT False ELSE // Print the Body block and run its events RETURN True END
- The event "Before printing" of the Body block is used to manage the records of the data file:
- Assigning the values of items in the report controls.
- Reading the next record.
// Assign the values of items in the report controls ITEM_Company = Customer.Company ITEM_Name = Customer.CustomerName ITEM_Address = Customer.Address ITEM_ZC = Customer.ZC ITEM_City = Customer.City // Read the next record HReadNext(Customer)
- The event "After printing" of the Body block is used to manage a page break, should each page contain a single Body block.
Remark: In the description window of the Body block, the option "Page break after the block" is not applied for a report based on a programmed data source.
// Page break as long as records are still found IF HOut() = False THEN iPageEnd() END
Order of execution of the different WLanguage events The order in which the different WLanguage events are executed to read the records is presented in the following table: | | Order of execution of report events | Programming required to read the data |
---|
1. Opening the report | Reading the first record (HReadFirst for example). | 2. Reading the report data | Managing the end of the data file. | 3. Before printing the Body block | Assigning the values of items in the report controls and reading the next record (HReadNext for example). |
This page is also available for…
|
|
|
|