Mainframe Utility: JCLBLKSZ

Return to Mainframe Utilities Page

Module


ISREDIT MACRO (VAR1)
ISPEXEC CONTROL ERRORS RETURN
/**** SET MESSAGE DISPLAY ON/OFF BASED ON THE DEBUG SWITCH ***/
ISPEXEC VGET (DBGSWTCH) PROFILE
IF &DBGSWTCH = &STR(ON) THEN CONTROL MSG LIST CONLIST SYMLIST NOFLUSH
ELSE  CONTROL NOMSG NOLIST NOFLUSH NOPROMPT
/******************************************************************/
/* 'JCLBLKSZ' EDIT MACRO. SET UP OPTIMUM BLKSIZES FOR JCL         */
/* AUTHOR : DAVID LEIGH    DATE : 3-19-90                         */
/******************************************************************/

SELECT (&VAR1)
    WHEN (HELP) GOTO HELPSEC
    WHEN (WRITE) DO
        SET MSGFLAG =
        SET LINEPOS = &STR(LINE_AFTER)
    END
    WHEN (NOWRITE) DO
            SET MSGFLAG = MSGLINE
            SET LINEPOS = &STR(LINE_BEFORE)
        END
    OTHERWISE DO
        IF &STR(&VAR1) >    THEN +
            DO
                SET ZEDLMSG = &STR(VALID PARAMETER ARE "WRITE" OR +
                                   "NOWRITE".  DEFAULT IS "NOWRITE".)
                ISPEXEC SETMSG MSG(UTLZ001)
                EXIT CODE(12)
            END
        ELSE  +
            DO
                SET MSGFLAG = MSGLINE
                SET LINEPOS = &STR(LINE_BEFORE)
            END
    END
END

SET DEFAULTUNIT = &STR(3380)
ISREDIT RESET EXCLUDED
ISREDIT EXCLUDE ALL '*' 3
ISREDIT FIND FIRST 'DCB=' NX
SET SAVECC = &LASTCC

DO WHILE &SAVECC = 0
    SET INCR = &INCR + 1
    ISREDIT RESET LABEL
    ISREDIT LABEL .ZCSR = .BEGIN
    ISREDIT FIND NEXT P'¬' 3 NX
    IF &LASTCC > 0 THEN +
        DO
            SET END = &STR(.BEGIN)
        END
    ELSE +
        DO
            ISREDIT FIND PREV P'=' 4 NX
            ISREDIT (LN,CL) = CURSOR
            ISREDIT (LINENUM) = LINENUM .BEGIN
            IF &LN = &LINENUM THEN SET END = &STR(.BEGIN)
            ELSE +
                DO
                    SET END = &STR(.END)
                    ISREDIT LABEL .ZCSR = &STR(&END)
                END
        END
    ISREDIT FIND PREV P'¬' 3 NX
    ISREDIT (LN,CL) = CURSOR
    ISREDIT (LINENUM) = LINENUM .BEGIN
    IF &LN = &LINENUM THEN SET DD = &STR(.BEGIN)
    ELSE +
        DO
            SET DD = &STR(.DD)
            ISREDIT LABEL .ZCSR = &STR(&DD)
        END
    IF &INCR = 1 THEN ISREDIT (SLN,SCL) = CURSOR
    ISREDIT FIND FIRST 'UNIT=' &STR(&DD) &STR(&END) NX
    IF &LASTCC = 0 THEN +
        DO
            ISREDIT FIND NEXT P'$' .ZCSR .ZCSR
            ISREDIT (ULN1,UCL1) = CURSOR
            ISREDIT FIND NEXT ' ' .ZCSR .ZCSR
            ISREDIT (ULN2,UCL2) = CURSOR
            ISREDIT FIND FIRST 'CART' &UCL1 &UCL2 .ZCSR .ZCSR
            SET TAPECC1 = &LASTCC
            ISREDIT FIND FIRST 'TAPE' &UCL1 &UCL2 .ZCSR .ZCSR
            SET TAPECC2 = &LASTCC
            ISREDIT FIND FIRST 'AFF'  &UCL1 &UCL2 .ZCSR .ZCSR
            SET TAPECC3 = &LASTCC
            ISREDIT FIND FIRST 'DISK' &UCL1 &UCL2 .ZCSR .ZCSR
            SET DISKCC1 = &LASTCC
            ISREDIT FIND FIRST 'SYSDA' &UCL1 &UCL2 .ZCSR .ZCSR
            SET DISKCC2 = &LASTCC
            ISREDIT FIND FIRST '3380' &UCL1 &UCL2 .ZCSR .ZCSR
            SET DISKCC3 = &LASTCC
            IF &TAPECC1 = 0 OR &TAPECC2 = 0 OR &TAPECC3 = 0 THEN +
                SET UNITPASS = TAPE
            IF &DISKCC1 = 0 OR &DISKCC2 = 0 OR &DISKCC3 = 0 THEN +
                SET UNITPASS = 3380
        END
    ISREDIT FIND FIRST 'LRECL=' .BEGIN &STR(&END) NX
    IF &LASTCC > 0 THEN GOTO NEXT
    ISREDIT (LN,CL) = CURSOR
    SET A = &CL + 6
    ISREDIT CURSOR = &LN &A
    ISREDIT FIND P'#' &A &A .ZCSR .ZCSR FIRST NX
    IF &LASTCC > 0 THEN GOTO NEXT
    ISREDIT FIND NEXT P'$' .ZCSR .ZCSR NX
    ISREDIT (LN,CL) = CURSOR
    ISREDIT (DLINE) = LINE .ZCSR
    SET B = &CL - 1
    SET LRECL = &SUBSTR(&A:&B,&NRSTR(&DLINE))
    IF &STR(&UNITPASS) =      THEN SET UNITPASS = &STR(&DEFAULTUNIT)
    ISPEXEC SELECT CMD(%BLKSIZE &LRECL 0 BATCH DEVICE(&UNITPASS))
    ISPEXEC VGET (VBLKSIZE BLKSIZE) SHARED
    SET RECFM = F
    ISREDIT FIND FIRST 'RECFM=' .BEGIN &STR(&END) NX
    IF &LASTCC = 0 THEN +
        DO
            ISREDIT FIND NEXT '=' NX
            ISREDIT FIND NEXT P'¬' NX
            ISREDIT (LN,CL) = CURSOR
            ISREDIT (RECFM) = LINE .ZCSR
            SET RECFM = &SUBSTR(&CL:&CL,&STR(&SYSNSUB(1,&RECFM)))
        END
    IF &STR(&RECFM) = V THEN SET BLKSIZE = &VBLKSIZE
    ISREDIT FIND FIRST 'BLKSIZE=' .BEGIN &STR(&END) NX
    IF &LASTCC > 0 THEN +
        DO
            SET BLKSIZE = &STR(BLKSIZE=&BLKSIZE)
            SET BLEN = &LENGTH(&STR(&BLKSIZE))
            ISREDIT FIND LAST P'¬' 1 72 .ZCSR .ZCSR NX
            ISREDIT (LN,CL) = CURSOR
            IF &EVAL(71 - &BLEN) < &CL THEN +
                DO
                    SET PUNCT = &SUBSTR(&CL:&CL,&STR(&DLINE))
                    IF &STR(&PUNCT) = &STR()) THEN +
                        DO
                            SET NEWLINE = +
                                &SUBSTR(1:&CL - 1,&STR(&DLINE))&STR(,)
                            ISREDIT &LINEPOS .ZCSR = &MSGFLAG +
                                    '&NRSTR(&NEWLINE)'
                            ISREDIT FIND FIRST P'¬' 3 72 .ZCSR .ZCSR NX
                            ISREDIT (LN,CL) = CURSOR
                            ISREDIT &LINEPOS .ZCSR = &MSGFLAG +
                                    < 1 '//' &CL '&BLKSIZE)' >
                            IF &MSGFLAG =    THEN +
                                DO
                                    ISREDIT DELETE ALL .ZCSR .ZCSR
                                    ISREDIT LINE_BEFORE .ZCSR = +
                                MSGLINE +
                                '//* PREVIOUS VERSION OF THE LINE WAS:'
                                    ISREDIT LINE_BEFORE .ZCSR = +
                                MSGLINE +
                                            '&STR(&SYSNSUB(1,&DLINE))'
                                END
                        END
                    ELSE +
                        DO
                            ISREDIT FIND FIRST P'¬' 3 72 .ZCSR .ZCSR NX
                            ISREDIT (LN,CL) = CURSOR
                            ISREDIT &LINEPOS .ZCSR = &MSGFLAG +
                                    < 1 '//' &CL '&BLKSIZE&PUNCT' >
                        END
                END
            ELSE +
                DO
                    SET PUNCT = &SUBSTR(&CL:&CL,&STR(&DLINE))
                    IF &PUNCT = &STR()) OR &PUNCT = &STR(,) THEN +
                        SET NEWLINE = &SUBSTR(1:&CL - 1,&STR(&DLINE))+
                                      &STR(,&BLKSIZE&PUNCT)
                    ELSE +
                        SET NEWLINE = &SUBSTR(1:&CL,&STR(&DLINE))+
                                      &STR(,&BLKSIZE)
                    ISREDIT &LINEPOS .ZCSR = &MSGFLAG '&NRSTR(&NEWLINE)'
                    IF &MSGFLAG =    THEN +
                        DO
                            ISREDIT DELETE ALL .ZCSR .ZCSR
                            ISREDIT LINE_BEFORE .ZCSR = MSGLINE +
                                '//* PREVIOUS VERSION OF THE LINE WAS:'
                            ISREDIT LINE_BEFORE .ZCSR = MSGLINE +
                                    '&STR(&SYSNSUB(1,&DLINE))'
                        END
                END
        END
    ELSE +
        DO
            ISREDIT (LN,CL) = CURSOR
            SET A = &CL + 7
            ISREDIT CURSOR = &LN &A
            ISREDIT FIND NEXT P'-' &A 72 .ZCSR .ZCSR NX
            ISREDIT (LN,CL) = CURSOR
            ISREDIT (DLINE) = LINE .ZCSR
            SET NEWLINE = &SUBSTR(1:&A,&STR(&DLINE))&BLKSIZE+
                          &SUBSTR(&CL:72,&STR(&DLINE))
            ISREDIT &LINEPOS .ZCSR = &MSGFLAG '&NRSTR(&NEWLINE)'
            IF &MSGFLAG =    THEN +
                DO
                    ISREDIT DELETE ALL .ZCSR .ZCSR
                    ISREDIT LINE_BEFORE .ZCSR = MSGLINE +
                            '//* PREVIOUS VERSION OF THE LINE WAS:'
                    ISREDIT LINE_BEFORE .ZCSR = MSGLINE +
                            '&STR(&SYSNSUB(1,&DLINE))'
                END
        END
NEXT: +
    ISREDIT FIND LAST P'=' &STR(&END) &STR(&END) NX
    ISREDIT FIND NEXT 'DCB=' NX
    SET SAVECC = &LASTCC
END

IF &MSGFLAG = MSGLINE THEN +
    DO
        SET ZEDSMSG = &STR(PROCESSED &INCR DD(S))
        SET ZEDLMSG = &STR(*** "MESSAGE" LINE(S) INSERTED FOR +
                           &INCR DD STATEMENTS ***)
    END
ELSE +
    DO
        SET ZEDSMSG = &STR(&INCR DD(S) MODIFIED)
        SET ZEDLMSG = &STR(*** "DATA" LINE(S) WERE MODIFIED FOR +
                           &INCR DD STATEMENTS ***)
    END

ISPEXEC SETMSG MSG(UTLZ000)

ISREDIT RESET EXCLUDED
ISREDIT CURSOR = &SLN &SCL

EXIT

HELPSEC: +                                                              02480000
ISPEXEC SELECT PGM(ISPTUTOR) PARM(HELPSHEL)                             02490000
SET ZEDLMSG = &STR(*** HELP DISPLAYED FOR JCLBLKSZ UTILITY +            02490000
                   *** NO PROCESSING PERFORMED ***)                     02490000
ISPEXEC SETMSG MSG(UTLZ000)                                             02490000
EXIT
            


Documentation


 The JCLBLKSZ edit macro will automatically interrogate your JCL, find all the
 LRECL DCB parameters, calculate an efficient BLKSIZE parameter and insert it in
 the JCL.  Simply type JCLBLKSZ on the command line and press  and it
 does the processing.

 By default, JCLBLKSZ will insert an edit "message line" into the JCL before the
 line it would replace and show you what the BLKSIZE would be.  In ISPF 3.0 and
 higher, you could then use the MD (make data) line command and make the message
 into a data line.  Alternatively, you can specify the WRITE parameter when you
 invoke JCLBLKSZ and it will go ahead and delete the old line and replace it
 with the new line with the correct BLKSIZE parameter.

 You can have a BLKSIZE parameter in your DCB parameter, or you may leave it
 out.  Either way, JCLBLKSZ will create a correct new line and insert it into
 the JCL.
            


Leave a Reply

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