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.
Prerequisites
- You have installed and configured Z Refactoring Assistant as instructed in Getting started.
- You have built the GenApp project in the IBM AD Build Client as described in Prerequisite: Building the GenApp project.
- You have created a workspace as described in Tutorial for the Web UI: Isolating or extracting the Update Motor Policy functionality as a service.
Procedures
- If you are not yet on the Workspaces tab, launch your browser and go to https://<hostname>:9443.
- Select the workspace that you created in the previous tutorial and then click the Graph tab.
- 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 seeLGUPDB01
in the results. - Click the result item
LGUPDB01
and then press Enter. A table closure is computed and displayed as the following example.LGUPDB01
program node has dotted arrows pointing outwards, which denote the data access on tables and files from the respective node. - Click the Action Menu (
) 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.
- 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. - 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.ASlice 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. - Select the variable for which you want to get the data flow analysis. For example, select the
DB2-POLICYNUM-INT variable from the list.
- 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.
- Click Next. A new
Slice to new workbook
dialog is displayed. - Type a name for the workbook you create, for example, type Test.
- Optional: Specify a tag for the workbook and press Enter.
- 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. - 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.
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.