MainframeSupports
tip week 51/2010:

MainframeSupport wishes you a Merry Christmas and Happy New Year.

MainframeSupport ønsker dig en glædelig jul og et godt nytår.

The ISPF EDIT/VIEW command CHANGE has a built-in indentation algorithm which you probably are not aware of, when you perform a CHANGE <source> <target> where <target> contains more characters than <source>. In this situation EDIT has to shift the characters to the right of <source> the number of characters that <target> is longer than <source> to the right. It is OK to be confused about the previous sentence. I cannot express in a better way.

If EDIT thinks that the CHANGE command can only be carried out by pushing the rightmost non-blank characters over the edge in a record then the record is marked by ERR in the line-command area and the change is not carried out in the record. If there are two or more consecutive blanks to the right of <source> then they are reduced to a less number of blanks depending on how much longer <target> is compared to <source>. This is a good algorithm in most cases and probably the reason why you do not think about how EDIT executes the CHANGE command.

The other day I needed to carry out a change of & to && because && by a tool I was using was translated to & while & was treated as the beginning of a symbolic variable (like in JCL and CLIST). My problem was that the positions in the data record should be maintained when the tool replaced && with &. This did unfortunately not happen when two or more consecutive blanks occured somewhere to the right of the first &. I think an example will be better to emphasize the problem:

Before CHANGE & && ..: ABC &DEF GHI    JKL
After CHANGE & && ...: ABC &&DEF GHI   JKL

But I really wanted this result:

Before CHANGE & && ..: ABC &DEF GHI    JKL
After CHANGE & && ...: ABC &&DEF GHI    JKL

After some scrutiny of the ISPF EDIT/VIEW manual it was clear to me that there is no avaliable option to disable the indentation algorithm. CHANGE always removes blanks if possible. So what to do. Here is my solution:

  1. CHANGE ' ' x'FA' ALL
  2. CHANGE x'FA' ' ' 73 80
  3. CHANGE & && ALL
  4. CHANGE x'FA' ' ' ALL

The reason why I chose x'FA' to substitute blanks was that this character did not appear in the data I was editing. If all characters in data are displayable, you can use x'00'. In my case the record length was 80 so I chose to replace the last 8 characters with blanks. Please always remember to replace the last x characters with blanks. The above solution requires that all records ends with a number of blanks. If not, my solution will not work. If the data you are working on is located in a VB dataset and you are using PRESERVE ON the solution will also fail miserably, because the result of using it will be that all records will end up having full length which was not what you wanted. If you use PRESERVE OFF it will work fine except on those records not having enough trailing blanks.

If you have struggled with the same problem as above and you found a better solution, I will be happy to hear from you. Especially if you know how to disable the indentation algorithm used by EDIT.

Previous tip in english        Sidste danske tip        Tip list