Mainframe Utility: CPY

Return to Mainframe Utilities Page

Module


PROC 0 MEM(NUL) DSN()
/* ALLOWS BROWSING OF A COPY BOOK WHILE EDITING AND OPTIONALLY */
/* ENTERING THE DATA SET TO LOOK FOR THE MEMBER  IN */
/**********************************************************************
/* MODIFICATION 4/12/91 - DAVE LEIGH                                  *
/* ADDED CAPABILITY TO DISTINQUISH BETWEEN GSS AND SLSS SEARCHES,     *
/* ADDED THE CICS COPY LIBRARY TO THE SEARCH, INPROVED THE PARSING    *
/* PROCESSING TO FIND THE MEMBER NAME, ADDED EDIT AS WELL AS BROWSE   *
/* CAPABILITY (MADE "EDIT" THE DEFAULT), ADDED A "HELP" SECTION,      *
/* ADDED DEBUG CAPABILITY, AND ADDED DOCUMENTATION.                   *
/* MODIFICATION 10/23/92 - D SLEEMAN                                  *
/*    CHANGED TO BE USED AS AN EDIT MACRO OR A TSO COMMAND            *
/* MODIFICATION 12/07/94 - D LEIGH                                    *
/*    UPDATED SLSS COPYLIB CONCATENATION                              *
/*    ADDED UNISTAR LIBRARIES                                         *
/*    ADDED EXEC SQL INCLUDE CAPABILITY                               *
/**********************************************************************
CONTROL NOMSG NOLIST NOFLUSH NOPROMPT
ERROR DO
        SET &MODE=CLIST
        RETURN
      END
ISREDIT MACRO (TEMPDSN)
ERROR OFF

/*** CHECK THE DEBUG SWITCH ***/

ISPEXEC VGET DBGSWTCH PROFILE
IF &DBGSWTCH = ON THEN +
    CONTROL MSG LIST CONLIST SYMLIST NOFLUSH NOPROMPT
ELSE +
    CONTROL NOMSG NOLIST NOFLUSH NOPROMPT


IF &MODE = CLIST THEN +
  DO
    SET TEMPDSN = &DSN
    SET MEMBER = &MEM
  END

ISPEXEC CONTROL ERRORS RETURN
IF &STR(&TEMPDSN) = HELP THEN GOTO HELPSEC

/**********************************************************************
/* SAVE THE USER'S CURRENT LOCATION.                                  *
/**********************************************************************
IF &MODE ¬= CLIST THEN +
  ISREDIT (SLN,SCL) = CURSOR

/**********************************************************************
/* ATTEMPT TO DETERMINE IF THIS IS A GSS OR SLSS SEARCH               *
/**********************************************************************
IF &MODE ¬= CLIST THEN +
    DO
        ISREDIT (DATASET) = &TEMPDSN
        ISREDIT (MEMBER) = MEMBER
    END

IF &SUBSTR(1:2,&STR(&SYSUID)) = &STR(P@) THEN SET SEARCH = SLSS
IF &SUBSTR(1:2,&STR(&SYSUID)) = &STR(P#) THEN SET SEARCH = GSS
IF &SYSINDEX(&STR(SLSS.),&STR(&DATASET)) > 0 THEN SET SEARCH = SLSS
IF &SYSINDEX(&STR(GSS.),&STR(&DATASET)) > 0 THEN SET SEARCH = GSS
IF &SYSINDEX(&STR(SLS),&STR(&DATASET)) = 1 THEN SET SEARCH = SLSS
IF &SYSINDEX(&STR(GSS),&STR(&DATASET)) = 1 THEN SET SEARCH = GSS
IF &SEARCH =      THEN SET SEARCH = SLSS

/**********************************************************************
/* WHAT EDIT PROFILE NUMBERING SCHEME IS BEING USED?                  *
/**********************************************************************
IF &MODE = CLIST THEN +
  GOTO SKIPFIND
ISREDIT (X,Y) = NUMBER
IF &X = ON AND &SYSINDEX(&STR( COBOL),&STR(&Y)) > 0 THEN +
    DO
        SET COL1 = 1
        SET COL2 = 66
    END
ELSE +
    DO
        SET COL1 = 7
        SET COL2 = 72
    END

/**********************************************************************
/* GET OUT IF THIS IS A COMMENT LINE.                                 *
/**********************************************************************
ISREDIT FIND FIRST '*' &COL1 .ZCSR .ZCSR
IF &LASTCC = 0 THEN +
    DO
        SET ZEDSMSG = &STR(COMMENT LINE)
        SET ZEDLMSG = &STR(*** THIS IS A COMMENT LINE *** +
                           NO PROCESSING PERFORMED ***)
        ISPEXEC SETMSG MSG(UTLZ001)
        GOTO FINISH
    END

/**********************************************************************
/* FIND THE MEMBER NAME ON THE LINE.                                  *
/**********************************************************************
SET MEMBER =
ISREDIT FIND FIRST ' COPY ' &COL1 &EVAL(&COL1 + 55 + 3) .ZCSR .ZCSR
IF &LASTCC ¬= 0 THEN +
    DO
        ISREDIT FIND FIRST ' CICSCOPY ' +
                &COL1 &EVAL(&COL1 + 51 + 3) .ZCSR .ZCSR
        IF &LASTCC ¬= 0 THEN +
            DO
                ISREDIT FIND FIRST ' INCLUDE ' +
                        &COL1 &EVAL(&COL1 + 52 + 3) .ZCSR .ZCSR
                IF &LASTCC ¬= 0 THEN +
                    DO
                        SET ZEDSMSG = &STR(NO COPY VERB)
                        SET ZEDLMSG = &STR(*** COULD NOT FIND +
                                           "COPY", "CICSCOPY", OR +
                                           "INCLUDE" +
                                           VERB ON THIS +
                                           LINE ***)
                        ISPEXEC SETMSG MSG(UTLZ001)
                        GOTO FINISH
                    END
            END
    END
ISREDIT FIND NEXT P'¬' .ZCSR .ZCSR
ISREDIT FIND NEXT ' ' .ZCSR .ZCSR
ISREDIT FIND NEXT P'¬' .ZCSR .ZCSR
ISREDIT (LN,CL1) = CURSOR
ISREDIT CURSOR = &LN &EVAL(&CL1 + 8)
ISREDIT FIND PREV '.' .ZCSR .ZCSR
ISREDIT FIND PREV P'¬' .ZCSR .ZCSR
ISREDIT (NULL,CL2) = CURSOR
ISREDIT (MEMBER) = LINE .ZCSR
IF &CL2 < &CL1 OR &CL2 > &LENGTH(&STR(&MEMBER)) THEN +
    SET MEMBER =
ELSE +
    SET MEMBER = &SUBSTR(&CL1:&CL2,&STR(&MEMBER))

IF &STR(&MEMBER) =     THEN +
    DO
        SET ZEDSMSG = &STR(NO COPYBOOK)
        SET ZEDLMSG = &STR(*** COULD NOT FIND THE COPYBOOK NAME ON +
                           THIS LINE ***)
        ISPEXEC SETMSG MSG(UTLZ001)
        GOTO FINISH
    END
GOTO SKPCLIST

SKIPFIND: +
SET MEMBER = &MEM

/**********************************************************************
/* FIND FIRST OCCURANCE OF THE COPYBOOK MEMBER IN THE LIBRARIES       *
/**********************************************************************
SKPCLIST: +
SELECT
    WHEN (&SYSDSN('&TEMPDSN(&MEMBER)')=OK) +
        SET DSN = &STR(&TEMPDSN(&MEMBER))
    WHEN (&SYSDSN('&SYSUID..&SEARCH..COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(&SYSUID..&SEARCH..COPYLIB(&MEMBER))
    WHEN (&SYSDSN('&SYSUID..STR.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(&SYSUID..STR.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('QDEVL.STR.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(QDEVL.STR.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('PDBA.USSTRD00.DCLGEN(&MEMBER)')=OK) +
        SET DSN = &STR(PDBA.USSTRD00.DCLGEN(&MEMBER))
    WHEN (&SYSDSN('QQUAL.STR.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(QQUAL.STR.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('PDBA.USSTRQ00.DCLGEN(&MEMBER)')=OK) +
        SET DSN = &STR(PDBA.USSTRQ00.DCLGEN(&MEMBER))
    WHEN (&SYSDSN('&SEARCH..RFP.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(&SEARCH..RFP.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('MMODO.STR.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(MMODO.STR.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('PDBA.USSTRM00.DCLGEN(&MEMBER)')=OK) +
        SET DSN = &STR(PDBA.USSTRM00.DCLGEN(&MEMBER))
    WHEN (&SYSDSN('&SEARCH..PRD.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(&SEARCH..PRD.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('PEMER.STR.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(PEMER.STR.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('PPROD.STR.COPYLIB(&MEMBER)')=OK) +
        SET DSN = &STR(PPROD.STR.COPYLIB(&MEMBER))
    WHEN (&SYSDSN('PDBA.USSTRP00.DCLGEN(&MEMBER)')=OK) +
        SET DSN = &STR(PDBA.USSTRP00.DCLGEN(&MEMBER))
    WHEN (&SYSDSN('SYS4.CICS.COBLIB(&MEMBER)')=OK) +
        SET DSN = &STR(SYS4.CICS.COBLIB(&MEMBER))
    WHEN (&SYSDSN('SYS3.CACOMMON.PROD.CAIMAC(&MEMBER)')=OK) +
        SET DSN = &STR(SYS3.CACOMMON.PROD.CAIMAC(&MEMBER))
    WHEN (&SYSDSN('SYS3.ACF2CICS.PROD.ACFMAC(&MEMBER)')=OK) +
        SET DSN = &STR(SYS3.ACF2CICS.PROD.ACFMAC(&MEMBER))
    WHEN (&SYSDSN('CRS.V2R1M0.SELACOPY(&MEMBER)')=OK) +
        SET DSN = &STR(CRS.V2R1M0.SELACOPY(&MEMBER))
    OTHERWISE DO
        SET ZEDSMSG = &STR("&MEMBER" NOT FOUND)
        SET ZEDLMSG = &STR("&MEMBER" NOT FOUND IN ANY COPY LIBRARY)
        ISPEXEC SETMSG MSG(UTLZ001)
        GOTO FINISH
    END
END

/**********************************************************************
/* PERFORM THE EDIT/BROWSE                                            *
/**********************************************************************
ISPEXEC EDIT DATASET('&DSN')
SELECT (&LASTCC)
    WHEN (0 ¦ 4) DO
        SET ZEDSMSG = &STR("&MEMBER" EDITED)
        SET ZEDLMSG = &STR("&DSN" WAS EDITED)
        ISPEXEC SETMSG MSG(UTLZ000)
        SET BROWSE = NO
    END
    WHEN (14) DO
        SET ZEDSMSG = &STR("&MEMBER" IN USE)
        SET ZEDLMSG = &STR(UNABLE TO EDIT "&MEMBER" *** +
                           IN USE BY ANOTHER USER/TASK)
        ISPEXEC SETMSG MSG(UTLZ000)
        SET BROWSE = YES
    END
    WHEN (16) DO
        SET ZEDSMSG = &STR("&MEMBER" NOT FOUND)
        SET ZEDLMSG = &STR("&MEMBER" DOES NOT EXIT)
        ISPEXEC SETMSG MSG(UTLZ001)
        SET BROWSE = NO
    END
    WHEN (20) DO
        SET ZEDSMSG = &STR("&MEMBER" EDIT ERROR)
        SET ZEDLMSG = &STR(SEVERE ERROR "20" TRYING TO EDIT +
                           "&MEMBER")
        ISPEXEC SETMSG MSG(UTLZ001)
        SET BROWSE = YES
    END
    OTHERWISE DO
        SET ZEDSMSG = &STR("&MEMBER" EDIT ERROR)
        SET ZEDLMSG = &STR(ERROR CC "&LASTCC" TRYING TO EDIT +
                           "&MEMBER")
        ISPEXEC SETMSG MSG(UTLZ001)

        SET BROWSE = YES
    END
END
IF &BROWSE = NO THEN GOTO FINISH
ISPEXEC BROWSE DATASET('&DSN')
SELECT (&LASTCC)
    WHEN (0) DO
        SET ZEDSMSG = &STR("&MEMBER" BROWSED)
        SET ZEDLMSG = &STR("&DSN" WAS BROWSED)
        ISPEXEC SETMSG MSG(UTLZ000)
    END
    WHEN (12) DO
        SET ZEDSMSG = &STR("&MEMBER" IS EMPTY)
        SET ZEDLMSG = &STR("&DSN" HAS NO LINES *** UNABLE TO BROWSE)
        ISPEXEC SETMSG MSG(UTLZ001)
    END
    WHEN (14 ¦ 16) DO
        SET ZEDSMSG = &STR("&MEMBER" NOT FOUND)
        SET ZEDLMSG = &STR("&DSN" WAS NOT FOUND)
        ISPEXEC SETMSG MSG(UTLZ001)
    END
    WHEN (20) DO
        SET ZEDSMSG = &STR("&MEMBER" BROWSE ERROR)
        SET ZEDLMSG = &STR(SEVERE ERROR "20" TRYING TO BROWSE +
                           "&MEMBER")
        ISPEXEC SETMSG MSG(UTLZ001)
    END
    OTHERWISE DO
        SET ZEDSMSG = &STR("&MEMBER" BROWSE ERROR)
        SET ZEDLMSG = &STR(ERROR CC "&LASTCC" TRYING TO BROWSE +
                           "&MEMBER")
        ISPEXEC SETMSG MSG(UTLZ001)
    END
END

/**********************************************************************
/* RETURN TO THE SAME CURSOR POSITION AND GET OUT                     *
/**********************************************************************
FINISH: +
IF &MODE ¬= CLIST THEN +
    ISREDIT CURSOR = &SLN &SCL
EXIT

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


Documentation


 The CPY edit macro allows the user to place their cursor on a line in a
 COBOL/COBOL2 program which contains a "COPY xxxxxxxx" statement.  CPY then
 parses the line to determine the name of the COBOL COPYBOOK.  It searches
 through the standard copy libraries to find the first occurance of this member.
 If it finds this member, it attempts to edit it, if it cannot edit it, it
 attempts to browse it.
 The user can also use this command as a TSO command.  To use type: TSO
 CPY MEM(xxxxxxxx) statement.  It will then function the same as it does
 with the edit macro.
 You can override the standard concatenation by typing TSO CPY
 MEM(xxxxxxxx) DSN(uuunn.xxxx.copylib) and the search will start with
 your Library.  To overide the standard concatenation using the edit
 macro the command is CPY uuunn.xxxx.copylib.
            


Leave a Reply

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