Tutorial for the Web UI: Getting a backward data flow slice

Perform the tutorial based on the sample project GenApp to explore how to get a backward data flow slice.

Tutorial scenario

Many a time you need to understand how a variable gets the value that is used to update a database table or the query information from a database table. To meet these needs, you can perform a backward data flow analysis. In this tutorial, you will learn how to get a backward data flow slice for a variable that participates in a database operation. The slice shall consist of all the statements from all the programs in the backward call chain that play a role in determining the value of the variable. The tutorial performs a context sensitive analysis so that infeasible paths can be ruled out.

Assumption

The output of the backward data flow slice is presented in the form of a workbook. You can use the output in determining the code blocks that are needed for creating services by using the forward code slicing as explained in Tutorial for the Web UI: Isolating or extracting the Update Motor Policy functionality as a service.

The following tutorial is based on the assumption that you want to analyze the data access of the program LGUPDB01 and then get a backward data flow slice on the Read variables in SQL queries.

Note: The current version of IBM® watsonx Code Assistant™ for Z Refactoring Assistant supports backward data flow slicing only on Read variables present in SQL queries.

Prerequisites

Procedures

Complete the following steps to perform the tutorial:
  1. If you are not yet on the Workspaces tab, launch your browser and go to https://<hostname>:9443.
  2. Select the workspace that you created in the previous tutorial and then click the Graph tab.
  3. On the Graph tab of Z Refactoring Assistant, choose the program for which you want to analyze the data access. For demonstration purpose, the program LGUPDB01 is used in this tutorial. Type LGUPDB01 in the search box. You will see LGUPDB01 in the results.
  4. Click the result item LGUPDB01 and then press Enter. A table closure is computed and displayed as the following example.
    The image shows a table closure as an example.
    In the flow chart, you can see that the LGUPDB01 program node has dotted arrows pointing outwards, which denote the data access on tables and files from the respective node.
  5. Click the Action Menu (The image shows the Action Menu icon.) icon on the upper right corner of the LGUPDB01 program node and select the Identify table/file access statements option. You will be directed to the Workbook tab of the LGUPDB01 program.
  6. From the Key conditions pane, click the SQL statement of interest. The source code view will show you the corresponding lines of code for the selected SQL statement. For example, click EXEC SQL (line 475), you can see the text highlighted in yellow in the source code view as shown in the following screenshot.
    The image shows the source code view.
  7. In the source code view, right-click the highlighted text EXEC SQL and then select Slice on variable to new workbook for data flow analysis.
    The image shows the Slice on variable to new workbook for data flow analysis option.
    A Slice to new workbook dialog is displayed as the following example. The dialog shows the direction of slicing and presents a list of Read variables available in the SQL statement on which data flow analysis can be performed.
    The image shows the Slice to new workbook dialog.
  8. Select the variable for which you want to get the data flow analysis. For example, select the DB2-POLICYNUM-INT variable from the list.
    The image shows an example when the variable DB2-POLICYNUM-INT is selected.
  9. Leave the Context sensitive analysis checkbox as selected by default.
    Note: When the Context sensitive analysis checkbox is selected, the analysis will try to eliminate infeasible paths and make the analysis results more precise. However, the analysis can be more time-consuming in the meantime. Since the analysis relies on static analysis data, some degree of imprecision might still be found in the data flow analysis and the slice might show some infeasible paths.
  10. Click Next. A new Slice to new workbook dialog is displayed.
    The image shows the Slice to new workbook dialog.
  11. Type a name for the workbook you create, for example, type Test.
    The image shows the Slice to new workbook dialog where Test is entered as the workbook name.
  12. Optional: Specify a tag for the workbook and press Enter.
  13. Click Save to create the workbook. A new workbook pane is displayed on the left, which shows the service code blocks for the Test workbook that you created. You can find the EXEC SQL code block that you just sliced and the highlighted statements.
    The image shows the code block that you just sliced.
  14. Scroll up and down to see all the statements across the program call chain that are involved in the data flow for the chosen variable.
    The image shows the Workbook details page that you can scroll up and down.

Now, you have explored how to get a backward data flow slice to perform a data flow analysis for a variable. You can repeat the procedures to slice on other data access statements of interest for analysis.