Introduction
ISPF is my opinion seriously undervalued as a whole, but the ISPF editor specifically misses out on the spotlight it deserves. So while there are endless articles about modern IDE’s like VSCode, IDZ, Topaz etc., and don’t get me wrong, each of those tools is excellent in their own right, there are not nearly as many good articles about the ISPF editor. And even though you might spend most of your time in a modern IDE, or in a shell in an ssh terminal, having to use ISPF is simply unavoidable when you work on IBM Z, so you might as well enjoy it as much as you can.
So here are some of my tips to get to know the ISPF editor a little better.
Recursive editing
Suppose you’re happily editing a member and you want to copy in some content from a different member. Instead of splitting you’re screen and 3.4’ing your way to a second member, you can recursively start an editor ‘on top of’ the one you’re in by issuing the EDIT command on the command line, which will display the exact same screen as is behind Primary Option Menu item 2. Edit and your initial edit session is hidden but still there.
If your current editor shows a member in a certain PDS(E) and you want to recursively edit another member in the same PDS(E) you can provide the member name and skip the Edit menu.
One use case for doing this is to use the CUT command to copy a snippet from the ‘inner’ editor session to PASTE it in your ‘outer’ session (more on CUT and PASTE below).
When you’re done using the ‘inner’ editor session, just PF3 your way out and you’ll end up back in the ‘outer’ editor session.
Lesser known ways to start the ISPF editor
Edit an SDSF output file with SJ or SE
In SDSF you can use the SJ and SE line commands.
SJ will get you an ISPF editor session with a copy of the JCL that was submitted to produce this output. This allows you for example to edit the JCL and resubmit it, CUT pieces out of it or copy the JCL and save it in one of your PDS(E)’s.
SE in front of a job or an output file will get you an ISPF editor session with a copy of the output file instead of only browsing the content. This allows you all the goodies in the ISPF editor like excluding lines, picture find/regex find, cut & paste etc.
Edit a USS file with oedit
Most of us detest TSO OMVS to do USS (Unix System Services) stuff because of the klunky terminal you’re forced to use. But if you can get past that the prize is getting to use the oedit command which gets you our beloved ISPF editor, which in my opinion far outshines shell based editors like vi(m). An added advantage of oedit is that your OMVS shell is temporary put in the background and you’re back in plain old ISPF until you PF3 out of there and you’re back in the shell that was patiently waiting for you.
Another plus of using oedit is that it’s very good with tagged files in USS. So if you use the chtag command to label your USS files with their coded character sets (e.g. IBM-1047, ISO8859-1, UTF-8, etc) the ISPF editor will understand and show you readable content instead of the gibberish you sometimes get with other editors.
More on the chtag command here: https://www.ibm.com/docs/en/zos/latest?topic=descriptions-chtag-change-file-tag-information
One final note on oedit: you can specify a record length and have the ISPF editor limit your content to that record length, even though a USS file normally doesn’t have a record length.
For example: oedit -r 80 myjob.jcl
This can be useful if your USS file(s) are at some point copied to traditional data sets with a fixed record length.
Cut and paste
You know how you can type a C over the line numbers on the lefthand side in the ISPF editor to copy a single line, and how you can use a double CC on the starting and ending line of a block of text to copy the entire block? Well instead of providing a location in the current editor to copy into, you can issue the CUT command and have ISPF remember that line or block of lines in a named scratch pad. If you don’t provide a name ISPF will use the DEFAULT scratch pad, but if you issue for example CUT PART1 then ISPF will create a named scratch pad called ‘PART1’.
The line(s) that were put into a scratch pad can then be inserted into any other ISPF editor, including ones you open after the current one is closed. These scratch pads are remembered for the duration of your ISPF session.
You can also add parts to a pre-existing scratch pad with the APPEND parameter. So to add something to our PART1 scratch pad you would issue CUT PART1 APPEND.
A previously created scratch pad can be copied into your current ISPF editor by issuing the PASTE command which also will use the DEFAULT scratch pad if you omit a name, or it will use the named scratch pad you specify, e.g. PASTE PART1 and provide a location with A or B on the line numbers for After or Before.
If you’ve lost track of which named scratch pads you’ve created you can CUT DISPLAY and get a popup telling you which scratch pads exist and giving you options to deal with each one.
Picture and regex find
Picture find has been a feature in the ISPF editor since forever and allows you to search strings using a type of mask where certain characters are placeholders for a category of possible characters. For example, if in SDSF you put SE in front of a started task and want to look for errors and you know the error codes all start with 3 letters followed by 4 digits and the letter E at the end, you could use F P’>>>####E’ where > stands for any uppercase letter and # stands for any digit.
The meaning of each letter can be found here https://www.ibm.com/docs/en/zos/latest?topic=string-picture-strings-string1
Regex find came much later and works similar to picture find but uses regular expressions as search patterns, which is like picture find on steroids. Explaining regular expressions here goes a bit too far, just Google it and there’s plenty of good material to learn from.
I can however give some examples:
- F R'[A-Z]{3,5}[0-9]{3,4}(W|E|S)’
This looks for warning or error message codes that start with 3 to 5 letters followed by 3 to 4 digits followed by either the letter W or E or S. - F R’^//[A-Z0-9@#$].* EXEC ‘
This looks for a JCL EXEC statement, but not commented out ones. - F R’ EXEC (CICS|SQL) ‘
This looks for either EXEC CICS or EXEC SQL statements in your COBOL source.
Excluding lines
I’ve saved my favorite for last which is excluding lines from view. If you type a single X over the numbers to the left of a line and enter you hide that line. If you type a double XX on one line and another XX on another line you can hide a block of text from view.
Those lines are still there, but they’re just hidden from view. To reshow all hidden lines you issue RESET on the commandline. Alone this functionality doesn’t seem very helpful, but it’s power comes with interacting with many of the other commands in the ISPF editor. A lot of them allow a parameter of either X or NX which makes the command apply only to excluded or non-excluded lines.
For example, suppose a JCL ran into an error and stopped executing midway. You could use the RESTART parameter on the JOB statement, but sometimes restarting a STEP that runs a PROC can be tricky. You could also delete STEPs that are already executed and remember to exit the editor with a CANCEL otherwise those lines are deleted permanently.
However, next time you run into something similar, try this instead. Exclude the steps already executed and issue SUBMIT NX. The JCL you submitted doesn’t contain the hidden lines, but the member you’re editing is unaltered.
X is not just a line command but you can use it as a primary command also.
For example, suppose you’re not interested in any comment lines in your JCL, you can issue
X ‘//*’ ALL
and all of the comment lines will be hidden.
Another very common trick is to first hide all lines and then make certain lines visible again with a find command. For example, imagine you’re looking for all references to a certain variable in your COBOL source. You could:
X ALL;F MYVAR ALL
and focus on just the lines that contain MYVAR.
Suppose you have meticulously hidden some lines from view and wish to issue a find command without it causing hidden lines to reappear, find also accepts the X and NX parameters.
So F MYVAR NX would find the next occurrence of MYVAR in only the visible lines.
Remember CUT and PASTE from earlier? CUT is another of those commands that accepts the X or NX parameter. So if you exclude some lines and issue CUT NX you take all the lines left visible and copy those into the default scratch pad.
If you’re unsure if you’ve hidden a line too many you can use the FLIP command to reverse the view, so hidden lines become visible and visible lines become hidden.
The ISPF editor displays a single dashed line for every block of hidden lines. Those dashed lines accept line commands like D to delete them all, but also F to have the first of the hidden lines of that block reappear and L for the last of the hidden lines. Both also accept a number, so F5 unexcludes the first 5 lines of a block.
So many other tricks
There’s so much I haven’t covered yet but maybe one or some of these tricks gets you interested enough to dive into IBM’s documentation on the ISPF editor and see what else you can learn.
I do want to make one more honourable mention though and that is edit macro’s. This is a large topic that deserves its own article because it takes the ISPF editor from being great into being briljant. More on that later…
Deel dit bericht op LinkedIn