Debugging a Stored Procedure

In this section:

The Reporting Server browser interface has a Dialogue Manager Debugger tool. Using this tool, you can execute a procedure that contains Dialogue Manager commands while watching and changing the values of the Dialogue Manager variables in the procedure. You can set and remove breakpoints in the procedure, step into each line of code, step over execution of external procedures, continue to a breakpoint, execute an ad-hoc procedure, and open HOLD files created in the procedure. You can save the session information of one debug session.

While the procedure is executing, the Dialogue Manager Debugger shows the values of all local variables, global variables, and, if requested, system variables. If a TABLE request is executed, the debugger shows the FOCUS stack with the commands being executed. If a variable that has not been defined is used in the procedure, the Dialogue Manager Debugger prompts you for a value.

Note that when the Dialogue Manager Debugger is executing a procedure, it is not running that procedure in an interactive WebFOCUS environment, so interactive Dialogue Manager commands (such as -PROMPT) that require a response from the user are not executed. While in a debugging session, you can open multiple procedures and Master Files. Each opens in its own tab.

Using the Dialogue Manager Debugger

The Dialogue Manager Debugger is for use with WebFOCUS procedures that contain Dialogue Manager commands.

To open a procedure in the Dialogue Manager Debugger, right-click the procedure, point to Run Advanced, and click Debug.

The procedure opens in the Dialogue Manager Debugger, as shown in the following image.

The left panel displays the procedure with line numbers. The Debug panel displays the variables and stacks used in the procedure. Once you start execution, an output panel opens on the right showing all output.

The Debug panel displays the following items.

The Output panel shows report output and messages. It has an Output actions menu with the option Clear output, to clear the panel content.

Setting Breakpoints

To set a breakpoint, right-click a Dialogue Manager command line where you want the breakpoint to occur, and click Set Breakpoint.

A breakpoint is a stopping point for execution. You may want to set one or more breakpoints in order to examine or change variable values at those points, run an ad-hoc request, or open a HOLD file created in the procedure.

Once you set a breakpoint, a solid circle appears in the Brk column on that line of the procedure, and the breakpoint is added to the list of breakpoints in the Debug panel.

You can disable or clear a breakpoint by right-clicking the line where the breakpoint is set and clicking Disable Breakpoint or Clear Breakpoint. A disabled breakpoint appears as a white circle with only an outline.

You can also click the Breakpoint Actions menu in the Breakpoints section of the Debug panel and click one of the following options from the context menu.

If you click Add new breakpoint, a dialog box opens for you to enter a procedure name and line number for the breakpoint.

If the breakpoint is for the current procedure, leave the Focexec text box blank.

If you want to set a breakpoint at the entry point of the procedure (whether or not it has a Dialogue Manager command), leave the line number blank.

Click Submit to set the breakpoint.

You can also set a breakpoint at the end of a file, even if there is no Dialogue Manager command on the line. Click the Breakpoint Actions menu in the Breakpoints section of the Debug panel and click Add new breakpoint. Enter the line number, and click Submit.

Watching Variables

To add variables to a watch list, right-click Watch Local Amper Variables (&) or Watch Global Amper Variables (&&), and click either Add new amper variable or Add all amper variables.

By default, as variables are set or changed, they are listed under All Local Amper Variables (&) or All Global Amper Variables (&&). You can add specific or all variables to the Watch Local Amper Variables (&) list or the Watch Global Amper Variables (&&) list, if you want to change their values at a breakpoint.

If you click Add new amper variable, a dialog box opens in which you enter the name of the variable to watch (without the preceding ampersands).

The variable is added to the watch list, as shown in the following image.

Debugging Steps

To start the debugger, click Start debugging on the ribbon.

The commands for executing the procedure and running an ad-hoc request become active.

If the procedure references a variable that has not been given a value, a dialog box opens to prompt you for a value when the variable is encountered.

The following options are available from the ribbon.

File Options

Execution Options

The following options are available on the Options menu for a file open in a tab:

Editing a FOCEXEC or Master File in the Debugger

On the Focexec/Master actions menu of a FOCEXEC or Master File tab, click Edit.

The file opens in the text editor, as shown in the following image.

For information about using the text editor, see Editing a Stored Procedure.

Once you have made your edits, click Save. A message similar to the one in the following image displays.

When you click OK, the FOCEXEC or Master File will be saved, and the debugging session will be restarted.

Note: Depending on the edits you make to a procedure, you may have to adjust your breakpoints so that they occur on the lines at which you want to break.

Dialogue Manager Debugger Sample Session

The following procedure is named dmdbugger3.fex. It includes a variable named &CTR whose value is set in the procedure, and a variable named &REGION whose value is not set in the procedure. The procedure contains a TABLE request and two external requests. The first external request displays output and the second creates a HOLD file named cathold.

-SET &CTR = 1;
-TYPE REQUEST # &CTR;
TABLE FILE WF_RETAIL_LITE
SUM  DAYSDELAYED AS DAYS
BY TIME_MTH
WHERE BUSINESS_REGION EQ '&REGION'
WHERE_GROUPED DAYSDELAYED GT 200
ON TABLE SET PAGE NOPAGE
END
-RUN
-TYPE END OF REQUEST &CTR;
-SET &CTR = &CTR+1;
-TYPE REQUEST # &CTR;
EX baseapp/catfex2
-RUN
-TYPE END OF REQUEST &CTR;
-SET &CTR = &CTR+1;
-TYPE REQUEST # &CTR;
EX baseapp/catfex3
-RUN
-TYPE END OF REQUEST &CTR;
-TYPE END OF PROCEDURE

The following image shows this procedure open in the debugger, with breakpoints set on Dialogue Manager commands before and after each request. The breakpoints are listed on the Debug panel.

Clicking Start, then Step to next command stops at the first breakpoint. Click the plus signs (+) next to All Local Amper Variables (&) and All Global Amper Variables (&&). The value of the &CTR local variable is shown as 1. The value of the &&GEO_UNIFIED_ROLE global variable is shown as ON. The execution stack shows the name and line number of the procedure being executed, as shown in the following image.

Clicking Step into command opens the following dialog box that asks you to enter a value for the &REGION variable.

Entering EMEA and clicking Submit proceeds to the next Dialogue Manager command. REGION is added to the list of local variables, and the first message displays in the output window. Also, before the request is actually run, the TABLE commands to be executed are listed on the Focus Stack, as shown in the following image.

After the request is run, the output displays in the output window. The next request in the procedure is issued using a -INCLUDE command. The external procedure is opened in the debugger if the last debugger command was Step into command, or the last debugger command was Step to next command and the external procedure contains a breakpoint on a line that will be executed.

The last request in the procedure, run using an EX command, creates a HOLD file named cathold. After the request is run, but while the procedure is still running, you can open the HOLD file by clicking Open Hold File from the File menu, as shown in the following image.

A dialog box opens where you can enter the name of the hold file.

After you enter the name and click Submit, a report showing the HOLD file data displays in the output window, as shown in the following image.

To clear the output pane, click the Output actions menu, and click Clear output.

After the procedure finishes executing, the debugger stops. You can click Start to start a new execution.