Mainframe Utility: GENSYNS

Return to Mainframe Utilities Page

Module


/**********************************************************************
/* UTILITY: GENSYNS                                                   *
/* AUTHOR: DAVID LEIGH                                                *
/* FUNCTION: CREATE/DELETE DB2 SYNONYMS FOR A LIST OF USERS AND       *
/*           MAINTAIN THAT LIST.                                      *
/**********************************************************************
PROC 0 USER() +
       DBAS('D@UDAL D@ULLJ D@UJEF') +
       ACTION(CREATE) +
       VALID_ACTIONS('CREATE DROP') +
       DRIVER(PLATINUM) +
       VALID_DRIVERS('PLATINUM DSNTIAD') +
       EDIT +
       HELP
/*** CHECK THE DEBUG SWITCH ***/                                              02
ISPEXEC VGET DBGSWTCH PROFILE                                                 02
IF &DBGSWTCH = ON THEN +                                                      02
    CONTROL MSG LIST CONLIST SYMLIST NOFLUSH PROMPT ASIS                00000702
ELSE +                                                                        02
    CONTROL NOMSG NOLIST NOFLUSH PROMPT ASIS                            00000902

IF &HELP = HELP THEN GOTO HELPSEC
                                                                              02
ISPEXEC CONTROL ERRORS RETURN
/**********************************************************************
/* WIMPY SECURITY BY IGNORANCE                                        *
/**********************************************************************
IF &SYSINDEX(&STR(&SYSUID),&STR(&DBAS)) = 0 THEN +
    IF &STR(&USER) =      THEN SET USER = &SYSUID
    ELSE +
        IF &STR(&USER) ¬= &SYSUID THEN +
            DO
                SET ZEDLMSG = &STR(YOU MAY ONLY GENERATE SYNONYMS +
                                   FOR YOURSELF)
                ISPEXEC SETMSG MSG(UTLZ001)
                SET EXITCC = 20
                GOTO FINISH
            END
        ELSE
ELSE +
     IF &STR(&USER) =      THEN +
         SET USER = ALL

/**********************************************************************
/* EDIT ACTION                                                        *
/**********************************************************************
IF &SYSINDEX(&STR(&ACTION),&STR(&VALID_ACTIONS)) = 0 THEN +
    DO
        SET ZEDLMSG = &STR(INVALID ACTIONS.  VALID ACTIONS ARE:  +
                           &VALID_ACTIONS)
        ISPEXEC SETMSG MSG(UTLZ001W)
        SET EXITCC = 12
        GOTO FINISH
    END

/**********************************************************************
/* EDIT DRIVER                                                        *
/**********************************************************************
IF &SYSINDEX(&STR(&DRIVER),&STR(&VALID_DRIVERS)) = 0 THEN +
    DO
        SET ZEDLMSG = &STR(INVALID DRIVER.  VALID DRIVERS ARE:  +
                           &VALID_DRIVERS)
        ISPEXEC SETMSG MSG(UTLZ001W)
        SET EXITCC = 12
        GOTO FINISH
    END

/**********************************************************************
/* ESTABLISH SOME PROCESSING VARIABLES                                *
/**********************************************************************
/* INITIALIZE SEVERAL VARIABLES WHICH WILL BE USED LATER IN THE       *
/* PROCESSING.                                                        *
/**********************************************************************
OPEN_CONTINUE: +
CALL 'SYS2.USC1.LINKLIB(USERINFO)' '&SYSUID '
SET JCLDSN = &STR(&SYSUID..TEMP.GENSYNS)
SET JOBNAME = &STR(&SYSUID.GSY)
SET JOBNAME = &SUBSTR(1:8,&STR(&JOBNAME))
SET EXITCC = 0
SET LP = &STR((
SET RP = &STR()

/**********************************************************************
/* CREATE THE JCL                                                     *
/**********************************************************************
SET ZEDLMSG = &STR(*** CREATING JCL TO GENERATE SYNONYMS ***)
ISPEXEC CONTROL DISPLAY LOCK
ISPEXEC DISPLAY MSG(UTLZ001)
SET PARM = &STR(PARMS('&ACTION &USER &DRIVER'))

DELETE '&JCLDSN'

FREE DDNAME(ISPFILE)

ALLOCATE DDNAME(ISPFILE) DSN('&JCLDSN') +
                         NEW CATALOG +
                         UNIT(SYSDA) VOLUME(WRK$$$) +
                         SPACE(2,2) TRACKS RELEASE +
                         RECFM(F B) LRECL(80) BLKSIZE(23440) DSORG(PS)

ISPEXEC FTOPEN
ISPEXEC FTINCL GENSYNS
ISPEXEC FTCLOSE

FREE DD(ISPFILE)

IF &EDIT = EDIT OR &EDITJCL = EDITJCL THEN +
    DO
        SET ZEDLMSG = &STR(NOTE: YOU MUST SUBMIT +
                           THIS JCL YOURSELF.  IT +
                           WILL NOT RUN AUTOMATICALLY.)
        ISPEXEC SETMSG MSG(UTLZ001)
        ISPEXEC EDIT DATASET('&JCLDSN')
        SET EXITCC = 0
        GOTO FINISH

    END

SUBMIT '&JCLDSN'
SET ZEDLMSG = &STR(*** GENSYNS JOB SUBMITTED ***)
ISPEXEC SETMSG MSG(UTLZ000)

/**********************************************************************
/* CLOSE UP SHOP                                                      *
/**********************************************************************
FINISH: +
EXIT CODE(&EXITCC)

/**********************************************************************
/* DISPLAY ANY "HELP" WHICH IS AVAILABLE FOR THIS UTILITY             *
/**********************************************************************
HELPSEC: +
ISPEXEC SELECT PGM(ISPTUTOR) PARM(HELPSHEL)
SET ZEDLMSG = &STR(*** HELP DISPLAYED FOR GENSYNS UTILITY +
                   *** NO PROCESSING PERFORMED ***)
ISPEXEC SETMSG MSG(UTLZ000)
EXIT
            


Documentation


GENSYNS is a utility which will create DB2 synonyms for UNISTAR programmers on
the UNISTAR development tables (USSTRD00 creator) where one does not exist and
that table does not exist in the programmer's personal database.

SYNTAX:

COMMAND ===> gensyns {edit}

Optional parameter "edit" indicates that you wish to edit the JCL which is
created for you by the GENSYNS utility.  If this parameter is specified, you
must submit the JCL yourself.  If this parameter is not specified, GENSYNS will
create and submit the JCL necessary to perform the synonym creation.

GENSYNS is a two-phase process.  First, GENSYNS queries the DB2 catalog and
finds table and view names listed in the PLATINUM security table for which there
is not a synonym created for you.  If such a situation exists, it also checks to
see if that table has been "cloned" into your own personal database (and
consequently, a synonym is not required).  If the table has not been cloned and
the synonym does not exist, it writes the necessary DDL to create the synonym to
an output file.

The second phase invokes the PLATINUM batch processor to actually execute the
DDL on your behalf and create the synonym(s).

You only need to invoke GENSYNS when, after you've finished using a table(s) in
your personal database, you delete that table(s) and want to resume using the
UNISTAR development table(s) instead.

In the instance where a new person joins the UNISTAR team or a new table/view is
created for which people need synonyms, the DBA team will execute GENSYNS in a
global fashion to build all necessary synonyms at once.
            


Leave a Reply

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