HLASM editing tutorial
About this tutorial
For the tutorial, you will assume the role of an HLASM developer who has received a requirement to enhance the output from
ASAM1 to also write the hexedecimal value of a character string. The current version simply reads in a string from an input file, and writes the record number, column number headings, and the input string to an output file.
Install IBM Z Open Editor and its prerequisites such as Java as described in Getting Started.
To enhance the report, you need to import the source code first.
- In VS Code, click Terminal > New Terminal to open a terminal.
- In the Terminal window, navigate to the desired directory for the source code by entering, for example, the following command:
- To clone the source code from the Git repository, enter the git repository of the sample files:
git clone https://github.com/IBM/zopeneditor-sample.git
- After the clone is completed, click File > Open Folder. Then, in the Open Folder window, select the
C:/Users/Public/zopeneditor-sampledirectory that you cloned, and click Select Folder.
Review the source code.
The current sample application consists of one HLASM program (
ASAM1), one copybook (
REGISTRS), two JCL members to set up and run the application (
RUNASAM1), and the input data file (
ASAM1reads in the
FILEINdata file record as a character string, and then simply writes out the string to the output file
(Optional) As you view the source in VS Code, you can use the Outline view to efficiently explore and navigate the code of the program. Note that the Outline view can be used only after you have opened a file or program in VS Code.
If the Outline view is not already expanded, you can open it by clicking View > Open view > Outline. By looking through the items in this view, you can get an idea of what the program does at a high level.
ASAM1.asmis a simple program to use in the editing tutorial so only one CSECT shows up in the Outline view. To see a more robust Outline view, you can open the
IRR@XACS.asmfile, an example from
IRR@XACS.asmfile serves as a better example to demonstrate the the Outline view and its capabilities, and you can further explore it as follows:
- Expand and collapse sections such as Dummy Sections (DSECT) and Control Sections (CSECT), and Macros in the Outline View.
- Go to a desired location in the code by clicking that section header in the view.
- Sort by Position, Name, or Type.
(Optional) In the
ASAM1.asmfile, you will see code syntax highlighting in the opened file, which helps you quickly distinguish between HLASM reserved words, comments, constants, and variables.
Unrecognized statements and expressions are highlighted in red, with which you can make quick corrections accordingly and reduce compile errors. Syntax checking also works for misspelled ASM reserved words and unknown variable names. To see all the syntax errors in the open files, click View > Problems or click the error and warning icon at the bottom in the status bar. Click the list item to directly go to the problem.
(Optional) Another visual feature of the editor is the grey lines that help with formatting as you code. You will notice the column 72 for the continuation character and the line at column 16 to show where a continued line can begin.
Modify the code in the
ASAM1.asmfile to also write the hexedecimal value of a character string to the output. When you enter code, the code completion capability provides you with matching lists from which you can select commands, defined variables, and code snippets.
For example, place your cursor at the end of line 40, and hit the Enter key to begin a new line on line 41. Try typing the command
BALR, and as you type, you can select from the lists of code completion suggestions that appear. You will also see a pop-up that displays the name of the command and the format of the command. Delete the new line you just typed on line 41 and continue with the tutorial.
(Optional) The hover feature works on variables and copybooks. You can hover over a variable to see its definition. You can hover over a copybook and the editor will resolve it and display it in a pop-up window. Once the copybook is open, you can Ctrl+Click(Windows) or Cmd+Click(Mac) to open the copybook in an editor window. Copybook resolution is based upon the
(Optional) The editor can show you all references of a variable or section in your code. When you double-click a variable or section name to highlight the entire name and then right-click it, you can see the following available actions:
Click Change All Occurrences: Ctrl+F2 (Windows) or Cmd+F2 (Mac)
When you type the new name, all occurrences are changed simultaneously.
Note: In the scroll bar on the right side of the editor, each occurrence is noted with a location bar.
Click Find All References: Alt+Shift+F12 (Windows) or Option+Shift+F12(Mac)
A Results References view for the variable or paragraph is displayed on the left side of the screen. Click any result to go to that location in the file.
Click Peek References: Shift+F12 (Windows and Mac)
A Results References view is displayed in the CodeLens box underneath the variable or paragraph. Click any result to go to that location in the file.
Click Go to Definition: F12 (Windows and Mac)
Go to the location where the variable or paragraph is defined. It opens the copybook or include if applicable.
Click Go to Symbol: Ctrl+Shift+O (Windows) or Cmd+Shift+O (Mac)
When you enter an object name in the search bar or you scroll through the items to select the object, the cursor is moved to that location.
Click Peek Definition: Alt+F12 (Windows) or Option+F12 (Mac)
This opens a CodeLens box that shows where the variable or paragraph was defined in the code.
Examine your code to analyze the impact of the requirement you received to determine the modifications needed. As you are to modify
ASAM1, you need to search for all components that refer to the program.
To search for components referencing
ASAM1, you can utilize the advanced Search capabilities provided by the VS Code editor out of the box. Its Search view allows searching for strings as well as regular expressions across all files or a specific subset of files based on location or name patterns.
In the Explorer view, right-click in the background of the zopeneditor-sample, not showing any particular file or folder to initiate a search on all files:
Select Find in Folder...
Input the search term
ASAM1and press Enter.
You can review some of the other search options such as using regular expressions and specifying patterns for files and folders to be excluded or included in the search.
For example, to perform a regular expression search, select the .* icon and change the search term to
ASAM1.*and review the results. Results will appear in the Search panel.
Click on the result to navigate to that location file in the Editor panel.
Open the integrated Git in VS Code, and create an isolated branch called
write-hex-value, where no one but yourself can access the source code before you push the changes to the origin repository.
To create the branch:
- In VS Code on the lower left hand corner, click .
- Then, from the drop-down menu that is displayed at the top of VS Code, click Create new branch.
- Specify a branch name of
write-hex-value, and then press enter to confirm. The workspace is switched to the isolated
Commit your changes into your
Now that you have performed various code changes and refinements you can commit this file version of the application to the SCM to preserve and share it.
To commit your changes, click the Source Control icon on the left of VS Code. In the Source Control panel that opens, the changed program is listed in the CHANGES section. In the CHANGES section, hover on the
ASAM1.asmprogram name and click the Stage changes (+) icon to move your changes to the staging area. In the Message text box, enter a comment for the changes such as
Implemented Hex Value, and then click the Commit icon to commit your changes.
Congratulations on completing the tutorial. For a more comprehensive list of the available features for code editing, see Making code changes.