skip to main content
OpenEdge Reporting: Report Builder Deployment
Report Engine Table Interface : Running reports from an application
 
Running reports from an application
This section describes how to run reports from 4GL applications. It contains the following examples:
*Running report with a simple filter override (rbfilt1.p).
*Prompting for user input for the printer information (rbprint1.p).
*Prompting for user input for the filter information (rbfilt2.p).
*Generating a list of reports, printing the reports, and updating the RB-STATUS field (rbplist1.p).
*Generating a list of reports, prompting the user to select which reports to run, and running the reports (rblist2.p).
All the samples illustrate how to run Report Engine with a multi‑user database. The samples use the rbsample.prl report library and the OpenEdge Sports database.
To run the sample reports:
1. Create a database called Runtable containing the Report Engine table. You can use the database definition file (%DLC%\bin\rbreport.df) that contains loadable definitions for the RBREPORT table.
(Note that you can give the database any name you choose, and it can contain other tables, such as the tables that contain your report data.)
2. Create an MS-Windows icon with the following command on the command line:
 
-mproserv -db dbname -S servername -H hostname -N networktype
Note that dbname contains the full pathname of the Runtable database.
3. Double‑click the MS‑Windows icon to start the database server. The icon becomes minimized.
4. Start the Procedure Editor and connect to the Runtable database in multi‑user mode using the parameters shown in Step 2.
5. Run the procedures.
To run the procedures, you must specify the appropriate pathname for the Report Engine database and be connected to the Report Engine database in multi‑user mode. In the examples, “Runtable” is the Report Engine database name.
Running a report with a simple filter override
The rbfilt1.p sample procedure runs the Customer Discount report in the rbsample.prl report library with the specified filter override:
 
rbfilt1.p
DO TRANSACTION:
 
/* 1 */
  CREATE RBREPORT.  
 
/* 2 */
  ASSIGN 
    RBREPORT.RB-REPORT-LIBRARY    = "c:\dlc\src\aderb\rbsample.prl"
    RBREPORT.RB-REPORT-NAME       = "Customer Discount"
    RBREPORT.RB-PRINT-DESTINATION = "D"
    RBREPORT.RB-INCLUDE-RECORDS   = "O"    
    RBREPORT.RB-FILTER            = "IN-RANGE(Order-Line.Discount, 15, 30)"
    RBREPORT.RB-DISPLAY-STATUS    = yes
    RBREPORT.RB-DISPLAY-ERRORS    = yes.
    
/* 3 */
  RELEASE RBREPORT.  
END.
 
/* 4 */
RUN aderb\_prore.p(FALSE,
  "-db Runtable -S servername -H hostname -N networktype -rbdel"). 
The commented numbers correspond to the following step‑by‑step descriptions:
1. Create the RBREPORT record.
2. Assign values to the record, including the filter override condition.
3. Explicitly release the RBREPORT record so that Report Engine can use it.
4. Call _prore to invoke Report Engine and run the report with the filter override. Then use the Report Delete (-rbdel) parameter to delete the record from the Report Engine table when the procedure is done.
Prompting for user input for the printer information
The rbprint1.p sample procedure runs the Accts Receivable report in the rbsample.prl report library and prompts the user for the printer destination and printer name using the Report Engine built‑in prompting mechanism:
 
rbprint1.p
DO TRANSACTION:
 
/* 1 */
  CREATE RBREPORT.
 
/* 3 */
  ASSIGN
    RBREPORT.RB-REPORT-LIBRARY    = "c:\dlc\src\aderb\rbsample.prl"
    RBREPORT.RB-REPORT-NAME       = "Accts Receivable"
    RBREPORT.RB-PRINT-DESTINATION = "?"
    RBREPORT.RB-PRINTER-NAME      = "?"
    RBREPORT.RB-DISPLAY-STATUS    = yes
    RBREPORT.RB-DISPLAY-ERRORS    = yes. 
 
/* 3 */
  RELEASE RBREPORT.
END.
 
/* 4 */
RUN aderb\_prore.p(false,
  "-db Runtable -S servername -H hostname -N networktype -rbdel").
The commented numbers correspond to the following step‑by‑step descriptions:
1. Create the RBREPORT record.
2. Assign values to the record, but specify questions marks (?) for the printer destination and printer name fields. The question marks instruct Report Engine to prompt the user for input for those fields.
3. Explicitly release the RBREPORT record so that Report Engine can use it.
4. Call _prore to invoke Report Engine and run the report with the user prompts. As shown in the previous sample procedure, you use the Report Delete (-rbdel) parameter to delete the record from the Report Engine table when the procedure is done.
Prompting for user input for the filter information
The rbfilt2.p sample procedure runs the Customer List report in the rbsample.prl report library and prompts the user for minimum and maximum values for the filter condition, as shown on the following page:
 
rbfilt2.p
DEFINE VARIABLE high-value      AS INTEGER   NO-UNDO.
DEFINE VARIABLE low-value       AS INTEGER   NO-UNDO.
DEFINE VARIABLE rb-filter-value AS CHARACTER NO-UNDO.
 
/* 1 */
FORM" Enter Low  Value for CUSTOMER NUMBER: " low-value at 20 SKIP
  "Enter High Value for CUSTOMER NUMBER: " high-value at 20
  WITH FRAME test-frame CENTERED NO-LABELS.
 
/* 2 */
UPDATE low-value high-value WITH FRAME test-frame.
HIDE FRAME test-frame. 
 
/* 3 */
rb-filter-value = "Customer.CustNum >= " + STRING(low-value) + 
  " AND Customer.CustNum <= " + STRING(high-value).
 
/* 4 */
DO TRANSACTION:
  CREATE RBREPORT.
 
  ASSIGN 
    RBREPORT.RB-REPORT-LIBRARY    = "c:\dlc\src\aderb\rbsample.prl"
    RBREPORT.RB-REPORT-NAME       = "Customer List"
    RBREPORT.RB-PRINT-DESTINATION = "D"
    RBREPORT.RB-INCLUDE-RECORDS   = "O"
    RBREPORT.RB-FILTER            = rb-filter-value
    RBREPORT.RB-DISPLAY-ERRORS    = yes
    RBREPORT.RB-DISPLAY-STATUS    = yes.
  RELEASE RBREPORT.
END.
 
RUN  aderb\_prore.p (FALSE,
  "-db Runtable  -S servername -H hostname -N networktype -rbdel").
The commented numbers correspond to the following step-by-step descriptions:
1. Define a form for the prompt.
2. Prompt the user for filter information.
3. Assign the filter override condition to rb-filter-value.
4. Run the Customer List report with the filter override on the report.
Generating a list of reports, printing the reports, and updating the RB-STATUS field
The rbplist1.p sample procedure runs all the reports in the rbsample.prl report library and updates the RB-STATUS field. This procedure assumes that all of the reports in the list generated by _getname.p use the Sports database. Report Engine connects to the Sports database only once on startup, and the same connection is used for each report since the => syntax is used in the RB-DB-CONNECTION field of the RBREPORT table.
To run the rbplist1.p procedure with the rbsample.prl report library, execute the following command:
 
RUN rblist1.p ("c:\dlc\src\aderb\rbsample.prl").
Here is the rbplist1.p procedure:
 
rbplist1.p
/* 1*/
DEFINE INPUT PARAMETER report-library AS CHARACTER NO-UNDO.
 
/* 2 */
DEFINE VARIABLE current-report-name AS CHARACTER NO-UNDO.
DEFINE VARIABLE report-count        AS INTEGER   NO-UNDO.
DEFINE VARIABLE report-list         AS CHARACTER NO-UNDO.
DEFINE VARIABLE report-number       AS INTEGER   NO-UNDO.
 
/* 3 */
RUN aderb/_getname.p(report-library, OUTPUT report-list, 
  OUTPUT report-count).
 
/* 4 */
REPEAT report-number = 1 TO report-count:
  CREATE RBreport.
 
  ASSIGN
    current-report-name           = ENTRY(report-number, report-list)
    RBREPORT.RB-REPORT-LIBRARY    = report-library
    RBREPORT.RB-REPORT-NAME       = current-report-name
    RBREPORT.RB-DB-CONNECTION     = "sports => logsport"
    RBREPORT.RB-PRINT-DESTINATION = "D"
    RBREPORT.RB-DISPLAY-STATUS    = yes
    RBREPORT.RB-DISPLAY-ERRORS    = yes. 
  RELEASE RBREPORT.
END.
 
/* 5 */
RUN aderb\_prore.p(FALSE, "-db Runtable -S servername -H hostname 
  -N networktype -db c:\data\sports -1 -ld logsport -rbupds").  
 
/* 6 */
FOR EACH RBREPORT:
  MESSAGE "Status of Report ’" + RBREPORT.RB-REPORT-NAME + 
    "’: " + RBREPORT.RB-STATUS VIEW-AS ALERT-BOX.
  DELETE RBREPORT.
END.
The commented numbers correspond to the following step‑by‑step descriptions:
1. Define the input parameter to the procedure.
2. Define the variables used in the procedure.
3. Run _getname.p to generate a list of reports in the specified library.
4. Add the reports to the Runtable database.
5. Run each report record in the RBREPORT table using the connection to the database on the command line. Then, update the RB-STATUS field.
6. For each record, view RB-STATUS field as an Alert Box, then delete the record.
Generating a list of reports, prompting the user to select which reports to run, and running the reports
The rblist2.p sample procedure generates a list of all the reports in the rbsample.prl report library, prompts the user to specify which reports to run, then runs the reports. This procedure assumes that all of the reports in the list generated by _getname.p use the Sports database. Report Engine connects to the database only once on startup, and the same connection is used for each report since the’=>’ syntax is used in the RB-DB-CONNECTION field of the RBREPORT table.
To run the rblist2.p procedure with the rbsample.prl report library, execute the following command:
 
RUN rblist2.p("c:\dlc\src\aderb\rbsample.prl").
Here is the rbplist2.p procedure:
 
rbplist2.p
/* 1*/
DEFINE INPUT PARAMETER report-library AS CHARACTER NO-UNDO.
 
/* 2*/
DEFINE VARIABLE current-report-name AS CHARACTER NO-UNDO.
DEFINE VARIABLE report-count        AS INTEGER   NO-UNDO.
DEFINE VARIABLE report-list         AS CHARACTER NO-UNDO.
DEFINE VARIABLE report-number       AS INTEGER   NO-UNDO.
 
/* 3 */
DEFINE VARIABLE user-answer         AS LOGICAL   NO-UNDO.
 
/* 4 */
RUN aderb/_getname.p(report-library, OUTPUT report-list,
  OUTPUT report-count).
 
/* 5 */
DO report-number = 1 TO report-count: 
  current-report-name = ENTRY(report-number, report-list).
 
  MESSAGE  "Report Number" +  STRING(report-number) + " is ’" +
    current-report-name + "’.  Do you want to print it?"
    VIEW-AS ALERT-BOX QUESTION BUTTONS yes-no
    UPDATE user-answer.
 
  IF (user-answer) THEN DO TRANSACTION:
    CREATE RBREPORT.
 
    ASSIGN 
      RBREPORT.RB-REPORT-LIBRARY    = report-library
      RBREPORT.RB-REPORT-NAME       = current-report-name 
      RBREPORT.RB-DB-CONNECTION     = "sports => logsport"
      RBREPORT.RB-PRINT-DESTINATION = "D"
      RBREPORT.RB-DISPLAY-STATUS    = yes
      RBREPORT.RB-DISPLAY-ERRORS    = yes. 
    RELEASE RBREPORT.
  END.
END.
 
/* 6 */
RUN aderb\_prore.p (FALSE, "-db Runtable -S servername -H hostname 
  -N networktype -db c:\data\sports -1 -ld logsport -rbdel").
The commented numbers correspond to the following step‑by‑step descriptions:
1. Define the input parameter to the procedure.
2. Define the variables used in the procedure.
3. Define the user-answer variable to handle the user’s input.
4. Run _getname.p to generate a list of reports in the specified library.
5. Prompt the user and add the selected reports to the Runtable database.
6. Run the selected reports, then delete the table records.