MainframeSupports
tip week 05/2006:

I often use a feature in ISPF EDIT (and VIEW) called picture strings, which can be used in FIND and CHANGE commands. Picture strings make it possible to perform wildcard or generic searches for data. The best known generic search is FIND P'.' and is proposed by the ISPF editor itself when data contains non-displayable characters. But you can use many other characters than . which enables other generic searches.

To perform a generic search you must put the search string in quotes (use ' or ") and you must prefix or suffix the search string with a P. No blanks are allowed between P and the quote. In the search pattern blanks, numeric values and letters will represent themselves, but the following special characters will match more than one character:

= matches all characters
@ matches all letters (in Denmark @ is Æ)
# matches all numerics (in Denmark # is Ø)
$ matches all special characters (in Denmark $ is Å)
¬ matches all non-blank characters (in Denmark ¬ is ^
. matches all non-displayable characters
- matches all non-numeric characters
< matches all non-capital letters
> matches all capital letters

A FIND P'#' FIRST will find the first numeric character in the data. If you have a big file filled with numeric characters then a FIND P'-' will find the first non-numeric character if there is one. You are still able to narrow down the search area to specific lines or columns in the usual manner.

My own favourite use of picture strings is to change a part of data to blank characters. Maybe I am interested in the data in column 1-8 while the rest of the data is of no interest. Then I will blank them out using a C P'¬' ' ' 9 9999 ALL. Typical the ISPF editor will complain about 9999 being far more than the actual LRECL for the data. By pressing F1 the error message is expanded and the actual LRECL is displayed. Then I repeat the change command and type in the correct LRECL and hit Enter. After this operation only column 1-8 will contain data and the rest will be blank.

New ways of finding and changing data will emerge as soon as you get used to picture strings. Imagine the following data:

CURT DONALDSON
CAROL SMITH
LAURA ANDERSON
PETER HEMINGWAY
ANN BROWN
TOMMY JONES

These names have to be changed to names starting with a letter in upper case and the rest in lower case. You can do this starting with a CHANGE P'>' P'<' 2 80 ALL followed by a CHANGE P' <' P' >' ALL. That's all folks. As you can see picture strings are also allowed in the target string of a change command, but you can only use:

= leave all characters unchanged
< changes capital letters to lower case and leave all other characters unchanged
> changes lower case letters to capitals and leave all other characters unchanged

Picture strings are strong tools in searcing and changing data. I hope you will be or are just as pleased as I am with this feature.

Previous tip in english        Sidste danske tip        Tip list