Fixing compilation and runtime errors using AI code assistant
COBOL Upgrade Advisor for z/OS® enables you to resolve the compilation and invalid data runtime errors in your COBOL source code using AI code assistant.
Note:
To use the AI code assistant to resolve compilation or runtime errors,
- Save the source programs to a local folder. You can use Zowe™ CLI to download the files to your local workstation. For more details, see Zowe documentation.
- Define the mainframe‑to‑local folder mappings for the source files (
localSourceMap) and, if required, the copybook location (copybookMVSLoc) by editing the project configuration file.
Compilation errors
You can use the AI assistant to resolve the following compilation errors:
- 68/74 COBOL Standard syntax errors
- Program compilation errors
Note:
- When you open the source code for the project from the Side Bar, the compilation errors are highlighted in the code automatically.
- The errors are also displayed in the Problems panel in VS Code. To open this panel, select View, and then select Problems.
Runtime errors
You can use the AI code assistant to resolve the invalid data runtime errors that are identified in the invalid data detection scan. After the scan completes, the invalid data detection report is displayed.Follow these steps to identify the source location of the runtime error:
- Select Save report to save the report to a project.
- Edit the project configuration file, cuaz.config.json, to update the mainframe‑to‑local folder mapping for the source code location and to specify the copybook location.
- In the Runtime messages tab of the scan report, open the Program drop down list and select the source line associated with the error.
- If you are opening the source code for the first time, specify the source file location and listing location.
The source code opens with runtime errors highlighted.
Fixing errors with AI code assistant
- Using the options in CUAZ menu
-
- Open the context menu for the source line that contains the compilation or runtime error.
- Select CUAZ.
- Select Fix Compilation Errors with AI or Fix Runtime Errors with AI depending on the error type.
- Using Quick Fix
-
- Hover over the source line that contains the compilation or runtime error.
- Select Quick Fix.
- Select Fix code to resolve the error by using watsonx Code Assistant® for Z.
After the compilation and runtime errors are resolved, the updated programs are saved to the mainframe location defined in the source code location mapping.