Mainframe Utility: RELABEL

Return to Mainframe Utilities Page

Module


/* REXX ***************************************************************/
/* UTILITY: RELABEL                                                   */
/* AUTHOR: DAVID LEIGH                                                */
/* FUNCTION: THIS EDIT MACRO IS DESIGNED TO RE-ORDER THE LABEL NUMBERS*/
/*           IN JCL FOR MULTIPLE DATASETS STACKED ON A SINGLE TAPE. IT*/
/*           IS FOR TIMES WHEN A JOB ABENDS AND YOU NEED TO START     */
/*           STACKING DATASETS AT A NEW JOB STEP BEYOND THE ONE THAT  */
/*           ORIGINALLY HAD THE LABEL OF "1".                         */
/*                                                                    */
/*           TO EXECUTE THIS, YOU PASS THE NUMBER OF THE LABEL WHICH  */
/*           SHOULD NOW BECOME ONE.  RELABEL FINDS THAT LABEL AND     */
/*           RENUMBERS ALL SUBSEQUENT LABELS SO THAT THEY ARE         */
/*           INCREMENTED PROPERLY.  IT ALSO WORKS WITH MULTIPLE OUT-  */
/*           PUT DD'S IN A SINGLE STEP WHICH ALL NEED TO HAVE THE     */
/*           SAME LABEL NUMBER.  MULTIPLE OUTPUT DD'S IN THE SAME     */
/*           STEP WITH DIFFERENT LABEL NUMBERS WOULD NOT WORK WELL.   */
/*                                                                    */
/*           SYNTAX EXAMPLE:                                          */
/*                                                                    */
/*           COMMAND ===> RELABEL 5                                   */
/*                                                                    */
/*           IN THIS EXAMPLE, RELABEL WOULD FIND EACH "LABEL=(" AND   */
/*           FIND THE FIRST ONE WHERE THE LABEL IS 5 (OR 05 OR 005).  */
/*           IT WOULD CHANGE THE 5 TO A 1 AND LABEL 6 TO A 2 AND      */
/*           LABEL 7 TO A 3 AND SO ON.                                */
/*                                                                    */
/* MODIFICATION: RELABEL NOW LOOKS FOR THE VOL= PARAMETER AND         */
/*               REMOVES ANY REFERBACKS FOR THE LABEL=1 DD.           */
/**********************************************************************/
ADDRESS ISPEXEC
'CONTROL ERRORS RETURN'

ADDRESS ISREDIT
'MACRO (OPT)'

NEXTLAB = 1
LINELAB = OFF

/**********************************************************************/
/* LOOP THROUGH THE JOB LOOKING FOR LABELS TO CHANGE                  */
/**********************************************************************/
"FIND FIRST 'LABEL=(' NX"
DO WHILE RC = 0
    "(LINE) = LINE .ZCSR"
    PARSE VAR LINE PREFIX 'LABEL=(' LABEL ',' SUFFIX
/***/
/*** BUMP UP THE LABEL FOR THE NEXT HIGHER NUMBER ***/
/***/
    DO WHILE LABEL > OPT
        OPT = OPT + 1
        NEXTLAB = NEXTLAB + 1
    END
/***/
/*** IF THEY'RE EVEN NOW, CHANGE THEM TO THE NEW VALUE ***/
/***/
    IF LABEL = OPT THEN
        DO
            IF LINELAB = OFF THEN
                DO
                    "LABEL .ZCSR = .FIRST"
                    LINELAB = ON
                END
            LINE = PREFIX ¦¦ 'LABEL=(' ¦¦ NEXTLAB ¦¦ ',' ¦¦ SUFFIX
            "LINE .ZCSR = (LINE)"
            "FIND LAST P'¬' .ZCSR .ZCSR"
        END
/***/
/*** FIND THE NEXT ONE TO CHANGE ***/
/***/
    "FIND NEXT 'LABEL=(' NX"
END

/**********************************************************************/
/* GO BACK AND GET RID OF FIRST REFERBACK                             */
/**********************************************************************/
"FIND FIRST 'LABEL=(1,'"
DO WHILE RC = 0
    "FIND PREV ' DD '"
    "LABEL .ZCSR = .A"
    "FIND NEXT ' DD '"
    IF RC = 0 THEN
      DO
        B = '.B'
        "LABEL .ZCSR = .B"
      END
    ELSE B = '.ZLAST'
    "FIND FIRST ',REF=' .A" B
    IF RC = 0 THEN
      DO
        "(LINE) = LINE .ZCSR"
        PARSE UPPER VAR LINE PART1 ',REF=' PART2 ')' PART3
        "LINE .ZCSR = '"PART1 ¦¦ ')' ¦¦ PART3 "'"
      END
    "FIND LAST P'='" B B
    "FIND NEXT 'LABEL=(1,'"
END

/**********************************************************************/
/* TAKE THE USER BACK TO THE FIRST CHANGED LINE                       */
/**********************************************************************/
"LOCATE .FIRST"
"FIND FIRST P'=' .FIRST .FIRST"
            


Documentation


 This edit macro is designed to re-order the label numbers in JCL for multiple
 datasets stacked on a single tape. It is designed for times when a job abends
 and you need to start stacking datasets at a new job step beyond the one that
 originally had the label of "1".

 To execute this, you pass the number of the label which should now become "1".
 RELABEL finds that label and renumbers all subsequent labels so that they are
 incremented properly.  It also works with multiple output DD's in a single step
 which all need to have the same label number.  Multiple output DD's in the same
 step with different label numbers would not work.

 Syntax Example:

 COMMAND ===> relabel 5

 In this example, RELABEL would find each "LABEL=(" and find the first one where
 the label is 5 (or 05 or 005, etc.).  It would change the 5 to a 1 and label 6
 to a 2 and label 7 to a 3 and so on.

 So if you had a job that looked like the following:

 //STEP01    EXEC PGM=XXX
 //DD1 DD LABEL=(1,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(1,SL,RETPD=30),etc.......
 //STEP02    EXEC PGM=XXX
 //DD1 DD LABEL=(2,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(2,SL,RETPD=30),etc.......
 //STEP03    EXEC PGM=XXX
 //DD1 DD LABEL=(3,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(3,SL,RETPD=30),etc.......
 //STEP04    EXEC PGM=XXX
 //DD1 DD LABEL=(4,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(4,SL,RETPD=30),etc.......
 //STEP05    EXEC PGM=XXX
 //DD1 DD LABEL=(5,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(5,SL,RETPD=30),etc.......
 //STEP06    EXEC PGM=XXX
 //DD1 DD LABEL=(6,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(6,SL,RETPD=30),etc.......
 //STEP07    EXEC PGM=XXX
 //DD1 DD LABEL=(7,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(7,SL,RETPD=30),etc.......
 //STEP08    EXEC PGM=XXX
 //DD1 DD LABEL=(8,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(8,SL,RETPD=30),etc.......
 //STEP09    EXEC PGM=XXX
 //DD1 DD LABEL=(9,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(9,SL,RETPD=30),etc.......
 //STEP10    EXEC PGM=XXX
 //DD1 DD LABEL=(10,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(10,SL,RETPD=30),etc.......
1
 After a "relabel 5" it would look like:

 //STEP01    EXEC PGM=XXX
 //DD1 DD LABEL=(1,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(1,SL,RETPD=30),etc.......
 //STEP02    EXEC PGM=XXX
 //DD1 DD LABEL=(2,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(2,SL,RETPD=30),etc.......
 //STEP03    EXEC PGM=XXX
 //DD1 DD LABEL=(3,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(3,SL,RETPD=30),etc.......
 //STEP04    EXEC PGM=XXX
 //DD1 DD LABEL=(4,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(4,SL,RETPD=30),etc.......
 //STEP05    EXEC PGM=XXX
 //DD1 DD LABEL=(1,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(1,SL,RETPD=30),etc.......
 //STEP06    EXEC PGM=XXX
 //DD1 DD LABEL=(2,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(2,SL,RETPD=30),etc.......
 //STEP07    EXEC PGM=XXX
 //DD1 DD LABEL=(3,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(3,SL,RETPD=30),etc.......
 //STEP08    EXEC PGM=XXX
 //DD1 DD LABEL=(4,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(4,SL,RETPD=30),etc.......
 //STEP09    EXEC PGM=XXX
 //DD1 DD LABEL=(5,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(5,SL,RETPD=30),etc.......
 //STEP10    EXEC PGM=XXX
 //DD1 DD LABEL=(6,SL,RETPD=30),etc.......
 //DD2 DD LABEL=(6,SL,RETPD=30),etc.......
            


Leave a Reply

Your email address will not be published. Required fields are marked *