There are likely to be many different approaches depending on the objective
being speed or ease of use. I believe in the ease of use, and have attached
two Rexx programs to assist:
$1EMAC is an edit macro that can add the two lines to the bottom of every
member
$2ALLMEM is the driver program that will process all members of a PDS,
without worrying about specifying the member names, using LM services.
After placing these in your SYSEXEC, change $1EMAC to add the two lines or
make any other changes, and run the exec:
TSO $2ALLMEM mypds.to.change $1EMAC
I am glad if you find this useful, and if not, well, that's ok, too.
*don*
/* REXX Edit Macro to add two lines to the end of a member */
Trace "O"; /* Set tracing mode (off) */
Address "ISREDIT"; /* Set environment to ISREDIT */
"MACRO NOPROCESS"; /* Opening statement for macro*/
/* "----+----1----+----2----+----3----+----4----+----5----+----6----+----7
*/
l1 = "This is the first line to add 11-11-11-11
";
l2 = "This is the second line to add 22-22-22-22
";
"(#BOT) = LINENUM .ZLAST"; /* Get bottom line no */
"LINE_AFTER" #bot " = (L1)";
rc1 = rc;
"LINE_AFTER" #bot + 1 " = (L2)";
rc2 = rc;
$mac$rc = Max(rc1,rc2);
Address "ISPEXEC" "VPUT ($MAC$RC) PROFILE"
"END";
Exit 0;
/*- REXX -------------------------------------------------------------*
* Name : $$$$$$$2 *
* Function : This program will process all members of a PDS using *
* ISPF LM services, and calling an edit macro *
* Author : Don Johnson *
* Params. : PDS name (no quotes), and edit macro name *
* Called by: none *
* Calls : none *
* Changes : *
* DEJ 16Feb2011 Initial Version. *
* *
*--------------------------------------------------------------------*
* Processing - This program will take an input PDS name, and will *
* use LM services to initialize and get a list of *
* members to process. *
* Each member is edited in turn with an IMACRO, and the *
* edit macro specified will run inside that member. *
* Basic reporting will identify the file name, number *
* of members processed, skipped or in error. *
*--------------------------------------------------------------------*/
Trace "O";
junk = Time("R");
/* ================================================================ */
/* */
/* Determine if ISPF is active */
/* */
/* ================================================================ */
If Sysvar("SYSISPF") = "ACTIVE" Then Nop;
Else
Do;
ADDRESS "TSO" "CLEAR";
Say; Say "ISPF must be active to execute this Exec.";
Say; Say "Please start ISPF and reissue the command.";
Return 16;
End;
/* ===================== Initialize variables ===================== */
Parse Upper Arg pds macname .; /* Get file and edit macro */
memvar = " "; /* Holds members to process */
lmrc = 0; /* LM return code */
edit_ct = 0; /* # of members processed */
skip_ct = 0; /* # of members skipped */
err_ct = 0; /* # of members with errors */
EOMems = 0; /* End of member list */
/* ===================== Begin Processing ========================= */
Address "TSO" "CLEAR";
Say; Say Time() "Beginning process to edit PDS members...";
/* Set ISPEXEC environment */
Address "ISPEXEC";
/* Init PDS for processing */
"LMINIT DATAID(IDVAR) DATASET('"pds"') ENQ(EXCLU)";
lmrc = rc;
If lmrc /= 0 Then
Do;
Say; Say " RC" lmrc "has occurred for LMINIT";
Say " Possible bad file name";
Signal Close_Rtn;
End;
/* Open PDS */
"LMOPEN DATAID("idvar") OPTION(INPUT)";
lmrc = rc;
If lmrc /= 0 Then
Do;
Say; Say " RC" lmrc "has occurred for LMOPEN";
Signal Close_Rtn;
End;
/* Build member list */
"LMMLIST DATAID("idvar") OPTION(LIST) MEMBER(MEMVAR)";
lmrc = rc;
If lmrc /= 0 Then
Do;
Say; Say " RC" lmrc "has occurred for first LMMLIST";
Signal Close_Rtn;
End;
/* Loop through each member */
/* and edit to change it */
lmrc = 0;
Do While lmrc = 0;
/*
/* Skip mems starting @ or $ */
If Pos(Left(memvar,1),"@$") > 0 Then
Do;
Say " Member" Left(memvar,8) "Bypassed.";
skip_ct = skip_ct + 1;
End;
Else
*/
Do;
"EDIT DATAID("idvar") MEMBER("memvar") MACRO("macname")";
"VGET ($MAC$RC) PROFILE"; /* Get RC from edit mac */
If $mac$rc = 0 Then
Do;
edit_ct = edit_ct + 1;
/* if desired Say " Member" Left(memvar,8) "Processed"; */
End;
Else
Do;
err_ct = err_ct + 1;
Say " Member" Left(memvar,8) "Has Errors";
End;
End;
/* Get the next member */
"LMMLIST DATAID("idvar") OPTION(LIST) MEMBER(MEMVAR)";
lmrc = rc;
Select;
When (lmrc = 0) Then Nop;
When (lmrc = 8) Then EOMems = 1;
Otherwise
Do;
Say " RC" lmrc "has occurred for LMMLIST";
Signal Close_Rtn;
End;
End; /* Select */
End; /* While */
/* ===================== Finish Processing ======================== */
Close_Rtn:
If EOMems Then
Do;
Say; Say " Edit of" pds "complete:";
Say " " Right(edit_ct,9) "members processed";
Say " " Right(skip_ct,9) "members bypassed";
Say " " Right(err_ct,9) "members with errors";
End;
/* Close and Free LM dataset */
"LMCLOSE DATAID("idvar")";
"LMFREE DATAID("idvar")";
Say; Say Time() "Processing Complete - Elapsed time" Time("E");
Exit 0;
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html