Virtual Fields (DEFINE Statements)

In this section:

How to:

A virtual field is a field whose value is not stored in the data source but can be calculated from the data that is there. A virtual field takes up no storage space. It is created only when a user accesses the Reporting Object that includes the virtual field.

You use the Define Tool to create a virtual field. Using this tool, you specify the virtual field name, format, and the expression that defines the field. An expression enables you to combine fields, constants, predefined functions, and operators into an operation that produces a single value. For more information about defining fields, see the Creating Reporting Applications With Developer Studio manual.

When you define a virtual field, you must specify a field format type, length, and appropriate display options.


Top of page

x
Procedure: How to Create a Virtual Field
  1. Expand the Reporting Object in which you want to add a virtual field.
  2. In the browser, select the Define folder and click the Open button in the Reporting Object window. The Define Tool dialog box opens and displays any existing defines.
  3. In the browser, click New Define.

    In Developer Studio, right-click the Define folder and select Open in the Reporting Object window.

    The following dialog box opens (this dialog looks slightly different in the browser).

    Field List window

  4. In the Field box, type the name of the virtual field.
  5. In the Format box, type a field format.

    For detailed information about field formats, see Field Formats.

  6. In the input box below the field name, type the expression that defines the virtual field.
  7. Click OK to save the virtual field, close the Field Creator, and return to the Define Tool.
  8. In the Define Tool window, click OK to close the tool.

    You return to the Reporting Object window. The virtual field now appears in the field list when a user accesses this Reporting Object.

If you have finished working with the components of the Reporting Object, remember to click Done in the Reporting Object window to save the changes.

Note:


Top of page

x
Procedure: How to Edit a Virtual Field
  1. Expand the Reporting Object in which you want to edit a virtual field.
  2. Right-click the Define folder and select Open in the Reporting Object window.
    • In the browser, the Define Tool dialog box opens and displays any existing virtual fields. Select the virtual field you want to edit and click Edit Define.
    • In Developer Studio, from the Defined Fields tab, select the virtual field you want to edit.

    The Field Creator dialog box opens, displaying the expression for the selected field.

  3. Make changes to the field expression or format and click OK.

    The Field Creator dialog box closes and you return to the Define Tool.

  4. Click OK to exit the Define Tool.

    WebFOCUS saves the change and returns you to the Reporting Object window.

If you have finished working with the components of the Reporting Object, remember to click Done in the Reporting Object window to save the changes.

Note: Syntax and error checking are not performed on the commands you enter until the Reporting Object is executed.


Top of page

x
Procedure: How to Delete a Virtual Field
  1. Expand the Reporting Object in which you want to delete a virtual field.
  2. In the browser, select the Define folder and in the Reporting Object window, click the Open button.

    In Developer Studio, right-click the Define folder and in the Reporting Object window, select Open.

    In the browser, the Define Tool dialog box opens and displays any existing virtual fields.

  3. Delete your virtual field:
    1. In the browser, select the virtual field that you want to delete and click the Delete Define button.

      In Developer Studio, click the Defined Fields tab and select the virtual field you want to delete. Click the Delete button.

    2. Click OK to verify the deletion.

    WebFOCUS deletes the virtual field and returns you to the Reporting Object window.

    If you have finished working with the components of the Reporting Object, remember to click Done in the Reporting Object window to save the changes.


Top of page

x
Field Formats

How to:

You must specify a field format for every virtual field you create. You assign a format based on the values that the virtual field will hold. The field format specifies the following information:

You can specify the format type, length, and appropriate display options in the Format input box in the Define Tool dialog box, or you can use the Change format dialog box to assist you in defining the field format as shown in the following image. The following procedure describes how to use this dialog box.

The Format input box

In this dialog box, you can select format attributes from list boxes instead of typing the required syntax.



x
Procedure: How to Specify a Field Format
  1. In the Field Creator window, click Format to open the Change format dialog box.
  2. In the Format Types list, select the radio button to the left of the format type you want to assign to the virtual field.

    The default length for the format type appears in the Length box.

  3. If you want to change the format length, type a new value in the Length box and the Decimal box.

    Note: The Decimal box appears only for the Floating Point, Decimal, and Packed format types.

  4. If the Format Type is numeric or date, specify any report display options.
    • For numeric format types, select one or more options in the Edit Options list box.
    • For the Date format type, type the display option code in the Date Format box.
  5. Click OK.

    The Change format dialog box closes and you return to the Field Creator. The virtual field will have the field format you just specified.

    Note: Syntax and error checking are not performed on the commands you enter until the Reporting Object is executed.


Top of page

x
Field Format Types

There are three types of field formats: alphanumeric, numeric, and date.


WebFOCUS