Skip to main content

System Programmers' Tips and Tricks for ISPF Revisited

More on the ISPF Editor and SDSF.

In the November/December 2005 issue of eServer Magazine, Mainframe edition, I wrote an article titled "Systems Programmers' Tips and Tricks for ISPF." In that article, I promised to delve further into the capabilities of the ISPF Editor and offer some tips and tricks for using SDSF. This article delivers on that promise.

ISPF Editor

The ISPF Editor, invoked using either ISPF command-line option 2, or more often using DSLIST via the command-line option combination 3.4, is one of the most fully featured text editors available for any OS. Note that I say text editor since ISPF Edit isn't a graphical editor, although some of its prompting and modeling capabilities are a precursor to the syntax prompting of sophisticated editors now available under a GUI.

ISPF Edit is equivalent to the ubiquitous vi in UNIX* variants and the Notepad application built into Windows* systems. Notepad is perhaps the simplest of these three text-only editors; vi has similarly powerful editing features to those found in ISPF Edit.

My best advice for learning this editor is to first learn the basics, then learn how to discover more functionality as you need it. As a preliminary, the editor has two command modes (similar to vi): these are line commands and primary commands. Line commands are those entered on the line numbers at the left of the data in the edit screen, while primary commands are entered at the Command ===> prompt near the top of the screen-assuming you use Command Line at Top as discussed in my previous article.

Learn the basic line commands: D for Delete, C for Copy, I for Insert, M for Move and the block commands and use a pair of characters mentioned. So, for example DD on line 10, and DD again on line 20 will (D)elete all lines from 10 through 20 inclusive. Using the block command with the (A)fter and (B)efore line commands-for example MM on line 10 and MM again on line 20, then place an A on line 30-will move lines 10 through 20 from their current location to the line (A)fter line 30. Similarly, a B would place them (B)efore line 30.

As with block commands, you can use a single line-command character followed by a number (i.e., I5 will insert five blank lines before the current line, while D10 will delete the current line and the following nine lines).

If an editing task is taking significant time, investigate the help screen; the time invested here may save you many keystrokes and time to change your data.

More Commands

More advanced editing requires knowledge of the left- and right-shift operands: the COLS, BNDS, X and FIND/CHANGE commands. A right bracket-)-shifts the text on the current line one character to the right, while the left bracket-(-shifts text to the left. Following the line command with a number (i.e., )5) shifts the text five places to the right. Combine these with their block-command equivalents, and you can indent or pull back large blocks of programming code very effectively.

This is when the e(X)clude line command becomes useful because it removes the current line from the display window. As a block command, it removes all lines between the first XX and the next. You can exclude 10 lines with the line command X10.

Excluded text can be either selected or unselected for processing a FIND or CHANGE primary command. This is useful when you want to change all occurrences of a string except in a few places-and is especially useful when the data set is large or the string occurs in many places.

The primary commands FIND and CHANGE accept similar arguments. "FIND a" highlights the first "a" character occurring in the currently edited data set. Press PF5 to find the next occurrence. "CHANGE a b" does as the syntax suggests, and changes the first occurrence of "a" to a "b." Instead of pressing the Enter key after a CHANGE command, try PF; this highlights the first string to be changed rather than actually updating the text. Press PF6 to process the change command, then PF5 again to highlight the next occurrence. Continuing to press PF5 skips changing the highlighted text and simply finds the next occurrence.

An extension to the base syntax of both FIND and CHANGE introduces the parameters X for e(X)cluded and NX for (N)on-e(X)cluded lines. So, if you've used the XX block command to exclude a large part of your program code, you can then globally change one string into another either in the excluded lines or only in the visible lines (i.e., "FIND fred NX" finds the string "fred," but only in the Non-eXcluded lines on the screen, while "CHANGE fred joe ALL X" changes all occurrences of the string "fred" to "joe," but only in the lines you currently have eXcluded).

Another command using similar constructs is the e(X)clude primary command, which has a syntax virtually the same as the FIND command. To exclude all lines containing the string "robot," issue the following primary command: "X robot ALL." To then delete all of the other lines in the data set issue: "DEL ALL NX" (the opposite action is "DEL ALL X").

In the examples, I've generally quoted the target strings or the FIND/CHANGE commands, which is most often unnecessary unless the target contains embedded spaces or quotes. It may also be useful to know how to undo and exclude; the line commands (F)irst or (L)ast reveals lines in the excluded text, (RES)et removes the exclude altogether.

When editing data, one of my favorite primary commands is BNDS or BOUNDS. This command is complemented by a line-command BNDS that displays the current data editing boundaries. I usually use this in combination with the line-command COLS to display a column number across the top of the data.

The BNDS command accepts two arguments, start-Bound and end-Bound specified as column numbers. Set the data-editing boundary with a primary command like "BNDS 20 80." This confines all FIND/CHANGE, etc., commands to data between (inclusive) columns 20 through 80. This can be incredibly useful when generating simple data using a global CHANGE command limited by boundaries. In combination with an EDIT MACRO, it's possible to create quite complex data structures this way. I'll address EDIT MACROS more in a future article.

One important thing to remember about BNDS: they stick across edit sessions. So, if you used BNDS the last time you edited data, the same boundaries will apply to your next edit session, likely to be on a different data set. If you're not expecting it, this can be confusing; if a FIND or CHANGE command doesn't produce the results you expect, try typing a BNDS line command just to check your current boundary settings. To remove the boundary settings, type BNDS or BOUNDS with no parameters as a primary command.

Line labels serve as an alternative to the eXclude function when you want to restrict a global FIND/CHANGE command to certain parts of your data. Establish a line label using the dot character-place a ".a" on one line as a line command, then a ".b" on another line elsewhere in the data. Now issue a "FIND char .a .b" command, which only applies to the data between the two labels.

Help Topics

Learning more about the ISPF editor is easily done with the built-in help screens and functions. Press PF1 while editing a dataset to access a repository of useful commands and descriptions of techniques available in the editor. If an editing task is taking significant time, investigate the help screen; the time invested here may save you many keystrokes and time to change your data.

To use help, press PF1, then use the Enter key to scroll through screens as a tutorial or select a topic by number. You can fastpath to help screens from the command line by entering the screen's index number. Type INDEX on the command line to view the index numbers.

Among systems professionals, there's disagreement on the preferred setting of the cursor scroll value at the right-hand side of the command line in an edit session. This option takes three possible values: PAGE, HALF and CSR. I prefer CSR as I believe this gives the best default behavior of the PAGE setting.

Additionally, the CSR setting allows you to position the cursor at any column on any line and use a scroll key (PF7/8, 10/11) so that the line of interest is now at the desired edge of the edit window, revealing as much data surrounding the selected character as your screen space allows. To change the default, type the first character of the desired option (i.e., C, H or P).

Here are some more useful edit commands to know, with a very brief description of each:
  • REC ON/OFF: With REC ON, the editor automatically keeps several generations of backup for any data during an edit session. You can step through these backups with the UNDO command.
  • HEX ON/OFF: This is great for debugging codepage and character set-related issues.
  • UC/LC: This and the block- command versions (UCC/LCC) are like the CAPS command, but only apply to the block of data they reference or encase. To force an entire data set to upper or lower case, use a line command like UC9999 at the first line.
  • TS/TF: Text Split and Text Flow are rarely needed, but are valuable tools on the rare occasion you need to join or split rows of data.
  • CUT and PASTE-CUT takes the part of the data set covered by the current copy line command and places the text in a buffer. The PASTE command is then used to insert this data into another editor session.
  • HILITE: This is great for editing code in supported languages such as JCL or REXX. The next time you're editing some JCL, try the Primary Command HILITE JCL.
  • MODEL: This is a valuable tool for the ISPF Dialog coder. Try the MODEL command when editing some REXX or an ISPF dialog component source code.
  • SDSF
When using SDSF, I like to save keystrokes as much as possible. The most common thing I see other people doing in SDSF is tabbing or using the NewLine key to get to the job they want to examine in the list of jobs SDSF provides under either the DA or ST display options.

To avoid jumping down the list, I usually assume that I'll want to look at the most recent job I submitted. To get your most recent job output to the top of the list, issue the command SORT JOBID D; this will sort your jobs in (D)escending order by their job identifier. Generally, the most recent job will have the highest numbered identifier and be at the top of your list. Press the Home key then tab twice and you can enter "S" or "?"-depending on your preference-to peruse your job output with minimum keystrokes and fuss.

When viewing large jobs consisting of many sysout data sets or job steps (i.e., a CICS region), many people prefer to use the question mark at the first job-selection panel to expand the job into its constituent parts and then select the data set or job step they wish to examine. This makes a lot of sense. When viewing smaller job results, I tend to use the N for Next command. Just select the entire job with an S at the job selection panel and then type an "N" at the command line to skip to the job's next data set (you can jump to the third data set with N3).

One of the most useful diagnostic commands in SDSF, in my opinion, is SET DISPLAY ON. Despite occupying a valuable line of screen space in the job selection screens, I've lost count of the number of times this option has saved me from the embarrassing statement (usually put to another systems programmer): "I can't seem to find my output-it's simply gone."

The SET DISPLAY ON/OFF command adds or removes a line that displays your current job PREFIX, DEST and OWNER settings. If you forget that you used SDSF previously and you set an OWNER of USERA-since you submitted jobs under that user ID-then today you can't see your output, the display line will let you know why you haven't even selected your output to view in the first place.

Other valuable diagnostic tools available in SDSF include the two commands WHO and QUERY AUTH. WHO simply displays the information that SDSF has on your current identification, with the most useful being the ISFGRP setting determined from your access to RACF* resources or the ISFPARMS. QUERY AUTH informs you of the SDSF screens, options and commands available to you.

When viewing job output, it's useful to see the temporary files that JES creates as input data for job steps. Use the SET INPUT ON command to view this data.

Other useful SDSF commands include the ampersand character, which can be used to automate the pressing of the enter key. Type &5 into the SDSF command line, and the input inhibited icon will display at the bottom left of your emulator session. SDSF then updates the display as if you pressed "Enter" every five seconds.

Line commands available at either a job-selection screen or within a job expanded with the ? command, include useful capabilities such as:
  • XDC-Copy the selected data to an external file
  • SJ-Select the original JCL for the job
  • SE-Edit the output in an ISPF editor screen 
There are many others and I encourage you to review the online tutorials and help screens built into SDSF to discover more about these powerful commands.

A Final Question

I leave you with a question. Is it possible to turn off the drop-down menus-and regain the line of screen space occupied-in an editor session? Drop me a line if you know the answer and I'll see you next time.
IBM Systems Webinar Icon

View upcoming and on-demand (IBM Z, IBM i, AIX, Power Systems) webinars.
Register now →