Previous Topic Next topic Print topic


Debugging the Batch Application

You are going to debug the batch Bankdemo application using the JCL debugger.
Important: You need Enterprise Developer to debug applications as this feature is not supported in Enterprise Developer Personal Edition.

Starting the Bankdemo enterprise server

If the enterprise server is not yet started, you need to start it as follows:

  1. In Server Explorer, right-click BANKDEMO under Micro Focus Servers, then click Start.
  2. Right-click Micro Focus Servers again, and then click Refresh to see that the server has started.

Starting the debugger

The demonstration application includes around 60 programs and just eight of them, the ones which are included in the project, are debuggable. The default debugger in Enterprise Developer is the CICS Debugger. You need to select the JCL debugger to debug the batch Bankdemo application:

  1. In Solution Explorer, right-click the BankDemo project and click Properties.
  2. Click the Debug tab in the properties.
  3. Set Active Settings to JCL.
  4. Click File > Save All to save your changes.

To start the debugger:

  1. Click Debug > Step Into.

    Visual Studio enters debug mode and opens a few new windows.

    The application is now waiting for an event that will trigger the debugging.

Simple debugging

You can now look at some simple features inside the debugger. To submit the JCL job:

  1. In Solution Explorer, right-click ZBNKSTMT.jcl and click Submit JCL.
  2. Check the Output window (click View > Output to show the window, if it is hidden) to see the job has been submitted successfully.

    The debugger starts, and the IDE opens ZBNKEXT1.cbl for debugging, with the execution point set on the first line of Procedure Division.

Stepping through the code

The highlighted line of code is the one the IDE will execute next.

  1. Press F11 (Step Into) to execute the highlighted line.

    The PERFORM statement executes and takes you to the line starting with IF TIMER-START.

  2. Press F11 slowly a few more times until you reach line 18000.

Using Run To Cursor

  1. Scroll down the file and position the cursor on a line further down the code.
  2. Right-click the line in the editor and click Run To Cursor.

    The application runs and executes the instructions till the line you selected.

Using the debug windows

There are a number of default windows which you can use while debugging the application such as:

Autos
Shows the values of the data items on the current line you have stepped into.

Watch
This window shows the values of data items you have added to the watch list. To set a watch on a data item:
  1. Scroll up to line 5900 in ZBNKEXT1.cbl.
  2. Right-click WS-RECORD-COUNTER1 and click Add Watch.

    This adds the item to the Watch window so you can see how it changes as you step through the code.

There are some additional windows you can use as well. To open them:

  1. Click Debug > Windows and select a window from the list.
  2. Open the windows for Breakpoints, Watchpoints, Program Breakpoints, a number of one to four Memory windows:

    Note that the windows are stacked, with a tab running along the bottom of the window.

Looking at data values in debug mode

While debugging, you can preview the values of data items in the current context as follows:

  1. Open the ZBNKEXT1.cbl file and scroll down the code to line 24700.
  2. Hover over the WS-RECORD-COUNTER2 data item.

    This opens a pop-up with the value of the item in the current context:

  3. You can click to pin the pop-up to the editor window.

Setting a simple breakpoint

Open the Breakpoints window - currently, there are no breakpoints set in the program. You can set a simple breakpoint as follows:

  1. Scroll up the code to line 019100 of the ZBNKEXT1.cbl file.
  2. Double-click in the grey area to the left of this line or right-click the line and click Breakpoint > Insert Breakpoint.

  3. Do the same for line 019700.
    Note: You can enable and disable the breakpoints from the Breakpoints window.

  4. Click F5 to run the code.

    The execution of the code stops at the first breakpoint.

  5. Press F5 to resume the execution.

    You can see that ZBNKEXT1.cbl finishes and the debugger starts to debug the second program defined in the JCL.

    This program executes to completion and the job completes.

Setting a COBOL watchpoint

In native COBOL, you can set COBOL watchpoints on data items in the code, and watch the memory associated with that data item. You can add a COBOL watchpoint as follows:

  1. Scroll to line 9100 in the code of ZBNKEXT1.cbl file.
  2. Right-click WS-EXEC-PARM-LL and click Add COBOL Watchpoint.

    This adds the item to the COBOL Watchpoints window.

  3. Notice how the value of this data item changes as you step through the code.

Note: To view watchpoints, you need to restart debugging as previously shown.

Running CSI queries

You can use the COBOL Source Information (CSI) functionality and its Quick Browse dialog to obtain information about your program when you are debugging it.

  1. Open the SBANK00P.cbl file in the editor.
  2. Click the Quick Browse button (Quick Browse button) on the COBOL toolbar to start the CSI query control.
  3. Enter a simple query such as WS-*.

  4. Press Enter to run the query.

    The results are shown in the Micro Focus Code Analysis window:

Running COBOL reports

Enterprise Developer provides a few COBOL reports which you can run against your COBOL programs to help you understand and optimize them. For example, to run a report to identify any code that cannot be reached or executed, you need to run the dead data report:

  1. With the SBANK00P.cbl file still opened in the editor, right-click in the code and click Code Analysis > Unreferenced Data.

    The IDE shows the results in the Micro Focus Code Analysis window:

    Dead Code report

  2. Expand any of the lines in the report and double-click a line in the result to highlight the lines of code that include unreferenced data.
  3. Use the Code Analysis command to run any of the other available reports.

Stop debugging

Although the job has completed, the debugger is still waiting for the next event. To stop debugging:

  1. Click Debug > Stop Debugging.
Previous Topic Next topic Print topic