Once in a while members of the MainframeSupport tip user group ask for help about a subject they cannot find any tip about. Some time ago a member wanted a way to insert an extra line in a lot of members meeting certain conditions. There were a lot of good proposals, but it is not an easy task.
I thought a combinations of some of the tips I have written may be useful, so here is my solution. The tip can only be applied on member datasets being FB 80. Another limitation is the need of a direct link between the lines to be inserted or edited and the conditions determining that a line needs to be inserted or edited. In other words the tip cannot be used to add a line at the bottom of every member containing the text EASTER somewhere in the member. On the other hand it will be able to replace EASTER with APFOOL or add an easter greeting after each line containing the text EASTER:
The first step is mentioned in week 14/2009, while the last step is described in week 19/2009. The step in the middle uses ideas presented in week 48/2010. In short the first step unloads a member dataset to a flat file. The next step transforms the flat file from the first step into a flat file that can be processed by the last step and it also carries out the editing. The last step restores the edited flat file into a member dataset. Unfortunately it cannot replace the original member dataset unloaded in the first step. You can add an extra step to delete the original member dataset and then reload it into a new dataset having the same name as the original one. If the original dataset is allocated to other tasks you may use IEBCOPY to copy members from MY.TARGET.PDS back into MY.SOURCE.DATASET. Please be aware that any of the above methods of restoring the original member dataset destroyes any ISPF statistics data (who has edited the member and when and stuff like that) for all copied members.
The editing is done using DFSORT. Please note that column 1 is left untouched as it
contains a control character while the data is present in column 2-81. The first IFTHEN
transforms the member names created by IEBPTPCH to a format understandable by IEBUPDTE. The
second IFTHEN makes the editing you want. In this example a blank line is inserted after
all
Last but not least I am aware that all of the above may be carried out by IEBUPDTE. The problem is that the IEBUPDTE manual is very hard to read and understand. If you know how to solve the above problem using IEBUPDTE I would very much like to hear from you or tell the user group.