Using WebFOCUS Report Output in Maintain

How to:

One of the most common tasks WebFOCUS procedures can accomplish for your application is executing a report. Include report output in your application in one of the following ways:

Note: If you are using a FOCUS Database Server and are accessing Maintain procedures and WebFOCUS report procedures on the same WebFOCUS Server, you must access them in a particular way to ensure the integrity of your logical transactions. For more information, see Ensuring Transaction Integrity.

For more information on WebFOCUS reports, see the Creating Reporting Applications With Developer Studio and Creating Reports With WebFOCUS Language manuals.


Top of page

x
Procedure: How to Display the Output From a FOCUS Report on a Form
  1. Ensure the report contains the following line:
    ON TABLE PCHOLD FORMAT HTMTABLE
  2. Include the WebFOCUS report procedure in your project.
  3. Create a stack with one computed column named HTML, of the type A250.
  4. Execute the report procedure using the following syntax:
    EXEC procedure [KEEP|DROP] INTO stack;

    For more information on KEEP versus DROP, see Persistence Management.

  5. Display the contents of the stack using an HTML Object.

For an example of this method, see WebFOCUS Maintain Advanced Tutorial in the WebFOCUS Maintain Getting Started manual.


Top of page

x
Procedure: How to Use the Output From a WebFOCUS Report
  1. Ensure the WebFOCUS report procedure contains the following line:
    ON TABLE PCHOLD
  2. Include the WebFOCUS report procedure in your project.
  3. Create a stack with columns that match the names of the columns in the report.

    Note: If you do not know the names of the columns in your report, create a HOLD file, and then open the file description for the HOLD file to see the column names.

  4. Execute the WebFOCUS report procedure using the following syntax:
    EXEC procedure [KEEP|DROP] INTO stack;

    For more information on KEEP versus DROP, see Persistence Management.

Note: The default format of the WebFOCUS Server on which the report is executed must be HTML.



Example: Using an HTML Table to Display the Results of a WebFOCUS Report

Suppose you created the following report using WebFOCUS Developer Studio and included it in your project:

-* File FANREPT.FEX
TABLE FILE FANNAMES
ON TABLE SET PAGE-NUM OFF
ON TABLE SET PRINT ONLINE
PRINT FIRSTNAME AND COMPANY AND EMAIL BY LASTNAME
HEADING
"PAGE <TABPAGENO  "
ON TABLE NOTOTAL
-* This command directs WebFOCUS to hold the report results in a stack.
ON TABLE PCHOLD
ON TABLE SET STYLE *
UNITS=IN, PAGESIZE='Letter', LEFTMARGIN=0.250000, RIGHTMARGIN=0.250000,
    TOPMARGIN=0.250000, BOTTOMMARGIN=0.250000, SQUEEZE=ON,
    ORIENTATION=PORTRAIT, $
TYPE=REPORT, GRID=ON, FONT=TIMES NEW ROMAN, SIZE=10, COLOR=BLACK,
    BACKCOLOR=NONE, STYLE=NORMAL, $
ENDSTYLE
END

This report displays the Firstname, Company, and Email fields from the Fannames data source, sorted by the Lastname field. Note that the syntax contains the ON TABLE PCHOLD line.

You can execute this report from a WebFOCUS Maintain procedure and save the results in a data source stack. The names of the columns in the data source stack must correspond to the columns in the report (that is, FIRSTNAME, COMPANY, EMAIL, and LASTNAME).

  1. Create a Maintain procedure.
  2. Use the Fannames data source in your procedure:
    1. Right-click the procedure and click Use data sources.
    2. In the Use these Data Sources in Procedure dialog box, click the Display all files in the project paths button Display all files in the project paths button.
    3. Select fannames and click the right-arrow button .

    If fannames does not appear in the project path, see How to Add an Existing File to Your Project.

  3. Create a new data source stack by right-clicking the Maintain procedure, clicking New, and then clicking Data Source stack.
  4. In the Stack Editor, name the stack FanStack.
  5. In the Available fields box, expand the Fannames data source, and then the CUSTOMER segment.
  6. Using the right double arrow, move the SSN field to the Stack columns box.

    Stack Editor dialog box

  7. Click OK. You have defined the data source stack that receives the contents of the WebFOCUS report.
  8. Open the Maintain procedure in the Procedure Editor.
  9. After the line of Maintain code that defines FanStack (INFER), but before the Maintain code that displays Form1 (Winform Show), enter the following Maintain code:
    EXEC FANREPT INTO FANSTACK;

    You can type all of this code directly or you can generate the EXEC FANREPT part, either with the Language Wizard or by dragging FANREPT from the Project Explorer into the Procedure Editor. You must type INTO FANSTACK by hand.

  10. Open Form1.
  11. Select the HTML Table control HTML Table button on the Controls palette.
  12. Draw a large rectangle on Form1.

    WebFOCUS Maintain automatically opens the Control Columns dialog box. Ensure FanStack is selected in the list of data source stacks.

  13. Copy FIRSTNAME, LASTNAME, COMPANY, and EMAIL to the Table columns box.

    Control columns dialog box

  14. Click OK.

    Form1 example diagram

Now, when you run your application, WebFOCUS Maintain executes FANREPT and returns the results to FanStack. The HTML Table on Form1 displays the contents of FanStack.

Any formatting information in the report is lost (if you wish, you can apply new formatting using the Table Column dialog box). To view formatting inherent in the report, use the ON TABLE HOLD HTMTABLE option, instead of ON TABLE PCHOLD and view the results in an HTML Object.


WebFOCUS