Previous Topic Next topic Print topic


Debugging the Batch Application

You are going to debug the batch Bankdemo application.
Important: You need Enterprise Developer or Enterprise Developer for IBM zEnterprise to debug applications as this feature is not supported in Enterprise Developer Connect.

Starting the server

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

  1. Click the Server Explorer tab.

    If the tab is not visible, click Window > Show View > Other. Select Micro Focus > Server Explorer and then click OK.

  2. In Server Explorer, right-click the Bankdemo server and then click Start.

    Wait until the server has started. In the list of servers in Server Explorer, BANKDEMO still has a red square next to it. This is a refresh delay.

Viewing the debug configurations

The project has two pre-configured debug configurations; a CICS Debug and a JCL Debug one, that you will use to debug the batch and the online application.

  1. In the Team Developer Tree view, select the BANKDEMO project and then select Run > Debug Configurations....
  2. In the left-hand pane of the Debug Configurations dialog expand COBOL Enterprise Server.
  3. Click CICS Debug.
  4. Click the different tabs in the right-hand pane to see what debug settings are enabled for this configuration. Note that this configuration will be used with the BANKDEMO server.
  5. Click JCL Debug under COBOL Enterprise Server.
  6. Click the different tabs in the right-hand pane to see what debug settings are enabled for this configuration.
  7. Click Close to close the Debug Configurations dialog without saving any changes.

Starting the debugger

You can now start the debugger. It starts in the background until a program which is debuggable is triggered. The demonstration application includes around 60 programs and just eight of them, the ones which are included in the project, are debuggable. To start the debugger:

  1. In the Team Developer Tree view, select the BANKDEMO project and then select Run > Debug Configurations... from the menu bar.
  2. In the left-hand pane of the Debug Configurations dialog expand COBOL Enterprise Server.
  3. Click JCL Debug and then click Debug.
  4. You might receive a message about opening the Debug perspective when it launches. If you do, click Yes.

    This opens a new Debug pane, saying it is waiting for attachment. In addition, in the top right of the main screen, the view has changed from Team Developer to Debug:. You can switch between the Debug and Team Developerperspectives by clicking on the respective tab.

  5. Click the Team Developer tab for now.
  6. In Server Explorer, right-click the enterprise server and click Refresh.

    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 the Team Developer Tree view, expand the JCL Files folder.
  2. Right-click ZBNKSTMT.jcl and click Submit JCL to associated Server.
  3. Depending on what you have done before, you may receive a message to Confirm Perspective Switch. If you receive it, check Remember my decision and click Yes. If Eclipse does not switch to the Debug perspective automatically, click the Debug button, , in the right upper corner of the main Eclipse window to switch the perspective.

    This starts the debugger and 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 F5 to execute the line.

    The PERFORM statement executes and takes you to the line starting with IF TIMER. You can also see that a Variables view is now open in the IDE showing the current value of a data item on the line of code which is about to be executed.

  2. Press F5 slowly a few more times until you reach line 18000. Watch the code as you step through it and notice how the values of the variables change inside the Variables view.

Looking at data values

  1. Scroll to line 24700 of ZBNKEXT1.cbl.
  2. Hover the WS-RECORD-COUNTER2 data item.

    This provides you with details of the location, the size, the format, the number of times the field is used in the program, and the current value of the data item.

  3. To change the value of WS-RECORD-COUNTER2, right-click the data item and click Inspect COBOL.

    This opens a pop-up window showing the value of the data item. Currently, it is 00000.

  4. Click Add to Expressions View in the pop-up.

    This opens the Expressions tabbed view and adds the data item to it.

  5. On the row for WS-RECORD-COUNTER2, click the arrow next to the data item to expand it.
  6. In the repeated version of the field name, change the value from 00000 to 00006.

    The new value is used from this point.

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. This example shows details for data items starting WS-, such as the name, definition, and amount of times each item occurs in the program.

  1. Click the Quick Browse button (Quick Browse button) on the toolbar to start the Quick Browse dialog box.
  2. Enter a simple query such as WS-*.

    Quick Browse

  3. Click OK to run the query.

    The results are shown in the Search view.

    Query results

    To see more examples of CSI queries, start the Quick Browse dialog box again and press F1 to open the product help.

Setting a simple breakpoint

Check the Breakpoints view at the top right of the screen. Currently, there are no breakpoints set in the program. To set a simple breakpoint:

  1. Scroll down the code to line 019100.
  2. Double-click in the grey area to the left of this line or right-click in the same place and click Toggle Breakpoint.

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

  4. Use F5 to step through the code and F8 to execute it. Press F8 now.

    The execution of the code stops at the first breakpoint.

  5. Press F8 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.

Stop debugging

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

  1. Click Run > Terminate or click the terminate button, , in the debugger toolbar.

  2. Finally, switch back to the Team Developer Perspective.
Previous Topic Next topic Print topic