Adding a WebFOCUS Report to Your Application

In this section:

How to:

In the previous section, you added a welcome screen to your application with four menu options. One of these options, Show all Fans, does not do anything. You are going to add another form to your application that displays the results of a WebFOCUS report. This report procedure, fanrpt.fex, is one of the sample files that came with WebFOCUS.

Show all fans image example

You can use the results of a WebFOCUS procedure in your application in one of two ways:


Top of page

x
Procedure: How to Add a WebFOCUS Report to Your Application
  1. In the Explorer, open the Procedures folder.
  2. Make sure that Display all files is turned on. Either in the View menu, or by clicking the button on the Exploring toolbar.
  3. Right-click fanrpt.fex and click Add to project.

Top of page

x
Procedure: How to Define a Stack to Receive WebFOCUS Report Output
  1. Create a new data source stack in the Start procedure by right-clicking Start and clicking New data source stack.
  2. Give your stack the name HtmlStack.

    Up until this point, you have created data source stacks based on the fields of a data source. For this stack, you will create a custom column.

  3. Double-click New variable to open the Computed Stack Column dialog box.
  4. Give your column the name HTML (if you name it anything else, the report will not work).

    Stack Edition dialog box

  5. Click the Ellipsis button button to open the Type Wizard. The Type Wizard helps you assign a data type to your new column.
  6. Leave the Built-in Type and Simple choices, but change Integer to Alphanumeric and the size to 250.

    Type Wizard dialog box

    Notice at the bottom of the dialog box, that the Type Wizard uses an abbreviation of A250 to represent your data type choice.

  7. Click OK to return to the Computed Stack Column dialog box.

    Notice that the Type Wizard has transferred the A250 to the Type box. If you know the WebFOCUS abbreviation for your data type, you can type it directly here. You will also notice, as you continue to work in a project, that WebFOCUS Maintain saves the data types you have applied and lists them.

    Computed Stack Column dialog box

  8. Click OK to return to the Stack Editor.
  9. Click OK to confirm your new stack and close the Stack Editor.

Top of page

x
Procedure: How to Execute Report Output Into a Stack
  1. Create a new function in Start named ShowAllFans.
  2. Double-click ShowAllFans to open it in the Procedure Editor.
  3. Type the following text between Case ShowAllFans and EndCase:
    EXEC fanrpt INTO HTMLSTACK;

    Executing the ShowAllFans function runs the report and returns the results to HtmlStack.

  4. Close the Procedure Editor.

Top of page

x
Procedure: How to Display Report Output in an HTML Object
  1. Create a new form to show the report output.
  2. Name the form Show_Fans_Form.
  3. Give the form the title Show All Fans.
  4. Give it the Spiralbg background image.
  5. Place the image Showall.gif at the top of the form.
  6. Put a Back button on the form that closes the form.
  7. Add an HTML Object to your form. In the Control palette, select the HTML Object HTML control button control, and draw a box on your form.
  8. Double-click it to open the HTML Content Source dialog box.

    The HTML Content Source dialog box enables you to specify HTML code that determines what the HTML Object displays. You could enter it directly here, but you want to use the report output from fanrpt.

  9. Change Insert HTML content from As entered here to From a variable.
  10. Expand HtmlStack.
  11. Select HTML.

    HTML Content Source dialog box

  12. Click OK to close the HTML Content Source dialog box.
  13. Change the Overflow property for the HTML Object to 2 - Scroll.
  14. Close Show_Fans_Form.
  15. In the Project Explorer, right-click Welcome_Form, and in the shortcut menu, click Edit event handlers to open the Event Handler editor.
  16. In the list of controls, select WelcomeMenu.
  17. In the list of events, select ClickShowAllFans.
  18. Drag ShowAllFans from the Project Explorer into the Event Handler editor.
  19. Drag Show_Fans_Form from the Project Explorer into the Event Handler editor and select Show a Form from the pop-up menu. (Be sure to select Show_Fans_Form and not ShowFan.)

    Show a form dialog box

  20. Close the Event Handler editor.
  21. Deploy and run your application.

Top of page

x
Clearing HtmlStack

How to:

If you run your application, and enter and leave Show_Fans_Form multiple times in one session, you will notice that Show_Fans_Form displays multiple copies of the report.

Each time you enter Show_Fans_Form, WebFOCUS Maintain re-executes the report and places it in HtmlStack.HTML. This is Maintain language shorthand for the HTML column of the stack HtmlStack. However, since you did not clear the contents of HtmlStack.HTML before re-executing the report, the new report results get appended to whatever is already in the stack. You must clear HtmlStack before executing the report.



x
Procedure: How to Clear HtmlStack
  1. Open Start in the Procedure Editor.
  2. Find Case ShowAllFans.
  3. Before the line that executes the report (Exec fanrpt INTO HTMLSTACK;), enter the following code:
    Stack clear HtmlStack ;

    You can either type this code or use the Language Wizard to enter it.

  4. Close Start, save your project, and deploy and run it.
  5. Try entering Show_Fans_Form more than once. The stack is clear.

WebFOCUS