Calling a Procedure From the Current One
The Execute Wizard and the Include component enable you to call
another procedure from the current one.
The Execute component allows one procedure to execute or call
another procedure. The redesigned Execute Wizard allows you to view
and select available procedures and supply values for parameters
in the called procedure and also test that called procedure. The
called procedure behaves as a completely separate procedure, with
its own context.
Execute Wizard allows you to select the procedure that you are
supplying parameter values for. Once this procedure is specified,
Execute Wizard displays these parameters and prompts you to provide
values for them. You can provide values for all parameters in the procedure,
or can choose to provide values for only some of the parameters.
If you provide values for only some of the parameters, you must
provide values for the other parameters using another method. (For
example, values are passed from another part of the application.)
After providing parameter values, you can test the called procedure.
The Execute Wizard is available throughout all development areas
of the product: Projects, Data Servers, and Managed Reporting. When
working in Managed Reporting, the tool allows developers to use
Standard Reports available in the Domain or use procedures that
reside on the WebFOCUS Reporting Server.
Execute Wizard uses the WFDESCRIBE auto-prompting feature to
locate and pass parameters. To activate the WFDESCRIBE feature,
change the default value in the IBIF_wfdescribe setting in the cgivars.wfs
file.
The Include component allows one procedure to run another procedure
as if the second one were embedded in the first. In this case, the
procedure being included (called) has full access to variables defined
in the calling procedure. Using this tool, you can create an object that
includes another procedure within a host procedure. There is no
limit to the number of procedures that can be included.
x
Procedure: How to Call a Procedure With the Include Component
-
Open
the host procedure.
-
Click
and hold the component connector at the point at which you wish to
include the existing procedure.
The Component Connector toolbox opens.
-
Click
the Include button on the toolbox.
The Open dialog box opens.
-
Select
the procedure you wish to embed from the list, or type the name of
a new procedure in the File Name field.
-
Click Open.
Tip: The
Include component inserts the -INCLUDE command into the procedure
code. Right-click the Include object and choose Quick View from
the shortcut menu to see the -INCLUDE command.
x
Procedure: How to Execute a Procedure With the Execute Wizard
-
Click
the component connector at the point at which you wish to include
the existing procedure.
The Component Connector toolbox opens.
-
Click
the Execute button.
The Execute Procedure Wizard opens.
-
Select
the procedure you want to execute from the list of available procedures,
and click Next. The Execute Procedure Wizard
- Enter Procedure Parameters window opens:
The
Enter Procedure Parameters window contains a list of variables contained
in the procedure you are executing, and fields in which to enter
values for those variables. This screen will not appear if the procedure
you are calling does not have parameters.
-
Enter
the variable values you wish to use in the procedure you are executing.
If you do not wish to provide a value for a variable, uncheck the
Optional box next to the variable name.
-
Click Next.
The Execute Procedure Wizard - Summary window opens. This
window allows you to view the name of the procedure you are calling
and view the variables-value pairs.
-
Click Test
Procedure to ensure that the procedure runs properly.
If the procedure works properly, a report will display in your browser.
-
Click Finish to
insert the selected procedure into the current procedure.
Tip: The
Execute component inserts the EX command in the procedure code.
Hover your cursor over the Execute object to see the EX command.
If you wish to run the embedded procedure, right-click the Execute
object and choose Run from the shortcut menu.
Example: Calling a Procedure From Another Procedure
In
the following example, you will create two procedures. One procedure,
named SALESREP, will contain a sales report with variables. The
second procedure, called SVALUES, will contain the values for the
variables in SALESREP, and will execute SALESREP. The result will
be a sales report with variable values filled in.
Create the SALESREP procedure:
- Create a new
procedure named SALESREP.
- From the Create with
drop-down list, select Procedure Viewer.
The Procedure Viewer opens.
- Click on the Component
Connector, and select Report. Select the
SALES Master File and press Open. The Report Painter
opens.
- Create a Variable
field by right-clicking inside the Fields tab of the Object Inspector and
selecting New Report Variable Field.
- Enter CITY in
the Name input field.
- From the Accept List
area, select the Static list radio button.
- From the Variable
Type drop-down list, select the Single Select option.
- In the Data Context
area, select Values for field.
- Click on the Select
a field ellipsis to get the Value Retrieval dialog.
- Select the field CITY and
then click Get Data.
- Double-click on the
returned values to add them all to the Accept List.
- Click OK to
close the Variable Editor.
- The new variable
is visible in the Object Inspector by expanding the folder Variables
and then the Report Variables.
- Insert a Report
Heading and type Monthly Report for and add
Report Variable &CITY by dragging it from the Object Inspector.
When prompted to a insert variable as a field to be evaluated or
as a literal value (default option), select the default option of Insert
as literal value.
- Add the UNIT_SOLD and RETURNS fields
to your report, then select both fields in the layout and click
the Sum button in the toolbar.
- Create the
RATIO field by doing the following:
- Select Computes from
the Report menu. The Report Options window opens.
- Enter RATIO in
the Field input box.
- Enter D5.2 in
the Format input box.
- Enter 100
* (RETURNS/UNIT_SOLD) in the Expressions window.
- Click OK.
- Add the PROD_CODE field
to your report, and click By.
- Filter the
PROD_CODE field by doing the following:
- Select Where/If from
the Report menu. The Report Options window opens.
- Select the Where tab.
- Enter the following
in the Expressions window: PROD_CODE FROM '&CODE1'
TO '&CODE2'
- Click OK.
- Add the CITY field
to your report, and click By.
- Filter by the
CITY field by doing the following:
- Select Where/If from
the Report menu. The Report Options window opens.
- Select the Where tab.
- Click New to
create a new expression.
- Enter the following
in the Expressions window: CITY EQ '&CITY'
- Click OK.
- Save and close
the procedure.
Create the SVALUES procedure:
- Create a new
procedure named SVALUES and from the Create
with drop-down list, select Procedure Viewer.
The Procedure Viewer opens.
- Click a component
connector, and select Execute. The Execute
Wizard opens.
- Select SALESREP from
the list of procedures, and click Next.
The
Enter Procedure Parameters window opens.
- Enter STAMFORD in
the Value field for CITY.
- Enter B10 in
the Value field for CODE1.
- Enter B20 in
the Value field for CODE2.
- Click Next.
The
Summary window opens.
- Click Finish.
You return to the Component Connector toolbox.
- Close and save
the procedure.
When the SVALUES procedure is run, the
following report appears.