ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Editors / Report editor / Programming a report
  • Overview
  • Creating a report with parameters
  • Overview
  • Example
  • Printing a report with parameters
  • Example
  • Tip
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
When printing a report, you have the ability to pass parameters to this report. The report is called "Report with parameters".
For example, your report corresponds to a mailshot sent to all the customers. The text of the mailshot is entered in a control before running this report. This text corresponds to a parameter expected by the report.
Report with Parameters
Creating a report with parameters

Overview

The creation of a report with parameters is performed in several steps:
  1. Creating a report.
  2. Modifying this report to support the parameters:
    • Retrieving the parameters in the "Open" event of the report via the following syntax:
      PROCEDURE <NomEtat>(<NomParam1>, <NomParam2>= "<ValeurParDéfautParam2>", ...
      ...
      <NomParamN> = "<ValeurParDéfautParamN>")

      Reminder: Some parameters passed to a procedure may be optional. When declaring the procedure, the optional parameters must be described in last position (on the right), with a default value preceded by the "=" sign. For more details, see Procedure parameters.
    • Using these parameters in the report controls.
  3. Modifying (if necessary) the application in order to specify the different parameters.
  4. Printing the report while passing parameters. For more details, see Printing a report with parameters.

Example

The program required to create a report with parameters is illustrated by the following example:
  • "RPT_ParamReport" corresponds to a mailing sent to customers.
  • This report expects the text of the mailing entered in "EDT_MailingText" as parameter.
Implementation:
  1. Create the "RPT_ParamRpt" report:
    • Click New in the quick access buttons.
    • The window for creating a new element is displayed: click "Report" then "Report".
    • The report creation wizard starts.
    • In the wizard, select "Mailshot" and validate.
      This report is linked to the "Customer" file of your analysis. For more details on how to create reports, see Reports.
  2. Customize this report.
  3. Write the following code in the "Open" event of "RPT_ParamReport":
    // Récupérer le paramètre passé à l'état et
    // passer un paramètre par défaut pour le test de l'état
    PROCEDURE ETAT_EtatParam(sTexte = "Valeur par défaut")
  4. In the Body block of this report, add the "STC_MailingText" static control used to display the text of the mailing.
  5. Write the following code in the "Before printing" of "STC_MailingText" event:
    // Récupérer le texte du mailing
    LIB_TexteMailing = sTexte
  6. In an application window, add:
    • the "EDT_MailingText" edit control allowing the user to type the text of the mailing.
    • the "BTN_Print" button used to print the report.
Printing a report with parameters
To print a report with parameters, you must:
  1. Set the report print destination with iDestination (report viewer, print in an HTML file, etc.).
  2. Specify the following parameters with iPrintReport:
    • the name of the report to print.
    • the parameters.
Remarks:

Example

"RPT_ParamReport" corresponds to a mailing sent to customers. This report expects the text of the mailing entered in "EDT_MailingText" as parameter.
"RPT_ParamReport" is printed when "BTN_Print" is clicked on.
In this example, the click code of "BTN_Print" is as follows:
// Ouvrir le visualisateur de rapports
iDestination(iViewer)
// Imprimer l'état avec passage de paramètre
iPrintReport(ETAT_EtatParam, SAI_TexteMailing)
Tip
To run the test of a report with parameters from the report editor, a default value should be given to the parameters in the parameter declaration.
For example, to test the report from previous example, enter the following code in the "Opening" of the report "RPT_ParamReport" event:
// Récupérer le paramètre passé à l'état et
// passer un paramètre par défaut pour le test de l'état
PROCEDURE ETAT_EtatParam(sTexte = "Valeur par défaut")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/07/2024

Send a report | Local help