Mainframe Utility: VIEW

Module


ISREDIT MACRO (OPT)
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
IF &OPT = &STR(HELP) THEN GOTO HELPSEC
/******************************************************************/
/* 'VIEW' EDIT MACRO. EDIT OR BROWSE A DATASET WHERE THE CURSOR IS*/
/* AUTHOR : DAVID LEIGH    DATE : 10-11-88                        */
/******************************************************************/

SET LP = &STR((
SET RP = &STR())

ISREDIT (LN,CL) = CURSOR
ISREDIT (DSN) = LINE .ZCSR

SET SYSDVAL = &SUBSTR(&CL:&LENGTH(&NRSTR(&DSN)),&NRSTR(&DSN))
READDVAL DSN

SET X = &LENGTH(&STR(&DSN))
SET Y = &SYSINDEX(&STR(&LP&RP),&STR(&DSN))

DO WHILE +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(.) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(?) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(") OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(') OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(:) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(;) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(&&) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(~) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(`) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(|) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(%) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(ª) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(*) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(_) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(-) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(=) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(+) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(!) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(?) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(?) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR() OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR({) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(}) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(/) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(>) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(<) OR +
   &SUBSTR(&X:&X,&STR(&DSN)) = &STR(&LP) OR +
   &SUBSTR(&X-1:&X,&STR(&DSN)) = &STR(&RP&RP) OR +
   &SUBSTR(&X-1:&X,&STR(&DSN)) = &STR(&LP&RP) OR +
   &SUBSTR(&X-1:&X,&STR(&DSN)) = &STR('&RP) OR +
   &SUBSTR(&X-1:&X,&STR(&DSN)) = &STR(&RP&LP) OR +
  (&SUBSTR(&X:&X,&STR(&DSN)) = &STR(&RP) AND +
  (&SYSINDEX(&STR(&LP),&STR(&DSN)) = 0)
    SET X = &X - 1
END

SET DSN = &SUBSTR(1:&X,&STR(&DSN))

IF &Y > 0 THEN SET DSN = &STR(&DSN&LP.0&RP)

/**  IF THIS IS A GDG FIND THE CORRECT VERSIONS *********/
IF &SYSINDEX(&STR(+),&STR(&DSN)) > 1 THEN +
    DO
        SET A = &SYSINDEX(&STR(+),&STR(&DSN)) - 2
        SET DSN = &SUBSTR(1:&A,&STR(&DSN))
        %GDGGEN DSN(&DSN)
        IF &LASTCC = 0 THEN +
            DO
                ISPEXEC VGET ZEROGEN SHARED
                SET DSN = &STR(&ZEROGEN)
            END
    END

IF &SYSINDEX(&STR(-),&STR(&DSN)) > 1 THEN +
    DO
        SET A = &SYSINDEX(&STR(-),&STR(&DSN)) - 2
        SET DSNX = &SUBSTR(1:&A,&STR(&DSN))
        %GDGGEN DSN(&DSNX)
        IF &LASTCC = 0 THEN +
            DO
                SET A = &A + 3
                SET B = &SYSINDEX(&STR(&RP),&STR(&DSN)) - 1
                SET X = &SUBSTR(&A:&B,&STR(&DSN))
                SET X = &X
                ISPEXEC VGET MINUS&X SHARED
                SET DSN = &STR(&SYSNSUB(2,&&MINUS&X))
            END
    END

IF &SYSINDEX(&STR(&LP.0),&STR(&DSN)) > 1 THEN +
    DO
        SET A = &SYSINDEX(&STR(&LP.0),&STR(&DSN)) - 1
        SET DSN = &SUBSTR(1:&A,&STR(&DSN))
        %GDGGEN DSN(&DSN)
        IF &LASTCC = 0 THEN +
            DO
                ISPEXEC VGET ZEROGEN SHARED
                SET DSN = &STR(&ZEROGEN)
            END
    END

LISTDSI '&DSN'
IF (&LASTCC = 4 AND &SYSREASON = 12 AND &SYSDSORG = VS) OR +
   (&STR(&OPT) = FILEAID) THEN +
    DO
        IF &STR(&OPT) = BROWSE THEN +
            ISPEXEC SELECT CMD(%$FB '&DSN')
        ELSE +
            ISPEXEC SELECT CMD(%$FE '&DSN')
        SET XMSG = &STR(UTLZ000)
        SET ZEDLMSG = &STR(FILE-AID INVOKED TO PROCESS "&DSN")
        GOTO FINAL
    END

SET XMSG = &STR(UTLZ000)
SET EDITCC = 0

IF &STR(&SYSDSN('&DSN')) = &STR(VOLUME NOT ON SYSTEM) THEN +
    DO
        %$TINFO '&DSN'
        GOTO FINAL
    END

SELECT (&STR(&OPT))
    WHEN (BROWSE) DO
        SET XMSG = &STR(UTLZ001)
        ISPEXEC BROWSE DATASET('&DSN')
        SELECT (&LASTCC)
            WHEN (12) SET ZEDLMSG = &STR(NO DATA TO BROWSE)
            WHEN (14) SET ZEDLMSG = &STR(MEMBER NOT FOUND)
            WHEN (16) SET ZEDLMSG = &STR(NO MEMBERS IN THE PDS)
            WHEN (20) SET ZEDLMSG = &STR(&SYSDSN('&DSN'))
            OTHERWISE SET XMSG = &STR(UTLZ000)
        END
    END
    WHEN (INFO) DO
        ISPEXEC VPUT DSN SHARED
        %INFODSN
    END
    WHEN (PDS) PDS '&DSN'
    WHEN (SUB) DO
         SUBMIT '&DSN'
         SET SUBCC = &LASTCC
         SET ZEDSMSG = &STR(SUBMIT CC: &SUBCC)
         SET ZEDLMSG = &STR("&DSN" WAS SUBMITTED.  CC: &SUBCC)
         ISPEXEC SETMSG MSG(UTLZ000)
    END
    OTHERWISE DO
        ISPEXEC EDIT DATASET('&DSN')
        IF &LASTCC > 4 THEN +
            DO
                SET ZEDLMSG = &STR("&DSN" BROWSED)
                SET XMSG = &STR(UTLZ001)
                ISPEXEC BROWSE DATASET('&DSN')
                SELECT (&LASTCC)
                    WHEN (12) SET ZEDLMSG = &STR(NO DATA TO BROWSE)
                    WHEN (14) SET ZEDLMSG = &STR(MEMBER NOT FOUND)
                    WHEN (16) SET ZEDLMSG = &STR(NO MEMBERS IN THE PDS)
                    WHEN (20) SET ZEDLMSG = &STR(&SYSDSN('&DSN'))
                    OTHERWISE SET XMSG = &STR(UTLZ000)
                END
            END
        ELSE +
            SET ZEDLMSG = &STR("&DSN" EDITED)
    END
END


FINAL: +
ISREDIT CURSOR = &LN &CL

ISPEXEC SETMSG MSG(&XMSG)

EXIT

HELPSEC: +
CLEAR
WRITE *** HELP FOR EDIT MACRO 'VIEW' ***
WRITE
WRITE THE VIEW EDIT MACRO ALLOWS THE USER TO TYPE VIEW ON THE COMMAND
WRITE LINE DURING AN EDIT SESSION, PLACE THE CURSOR ON THE BEGINNING OF
WRITE A DATASET NAME IN THE BODY OF THE FILE, PRESS , AND BE
WRITE TAKEN INTO AN EDIT OR BROWSE OF THAT DATASET.  ADDITIONALLY, A
WRITE PF KEY CAN BE SET TO THE STRING 'VIEW', AND THE USER COULD PLACE
WRITE THE CURSOR ON THE DATASET NAME, AND PRESS THE PF KEY, AND ACCOM-
WRITE PLISH THE SAME THING.
WRITE
WRITE BASIC SYNTAX :
WRITE
WRITE COMMAND ===> VIEW
WRITE 000108 //JS010    EXEC PGM=WAAPDSUT
WRITE 000109 //SYSUT1     DD DSN=TCWCA.TWB.WORKFILE(INDATA),
WRITE 000110 //              DISP=(SHR,KEEP,KEEP)
WRITE 000111 //SYSUT2     DD DSN=TCWCA.TWBAT.INDATA.COPY,
WRITE 000112 //              DISP=(NEW,CATLG,DELETE)
WRITE 000113 //              UNIT=TSTDA,
WRITE 000114 //              SPACE=(TRK,(1,1),RLSE),
WRITE 000115 //              DCB=(RECFM=FB,LRECL=80,BLKSIZE=23440)
WRITE
WRITE IN THE ABOVE EXAMPLE, THE CURSOR WOULD BE PLACED ON THE 'T'
WRITE IMMEDIATELY FOLLOWING EITHER 'DSN=' STRING (SYSUT2 WOULD BE AVAIL-
WRITE ABLE PROVIDING THAT THE JCL HAD ALREADY BEEN RUN), AND THE 
WRITE KEY WOULD BE PRESSED.  PROVIDED THAT THE USER HAD AUTHORITY, AND
WRITE THE DATASET WAS NOT IN USE, AND THE LRECL OF THE DATASET FELL
WRITE WITHIN THE ALLOWABLE LIMITS OF AN ISPF EDIT SESSION, THE USER
WRITE WOULD BE TAKEN INTO AN EDIT OF THE DATASET.
WRITE
WRITE IF THE RETURN CODE FROM THE ATTEMPT TO EDIT THE DATASET WAS UN-
WRITE SATISFACTORY, THE MACRO WILL ATTEMPT TO BROWSE THE DATASET
WRITE INSTEAD.  ACF2 VIOLATIONS, AND EXCLUSIVE ENQUEUES OF THE DATASET
WRITE WOULD BE THE ONLY FACTORS WHICH WOULD PROHIBIT A BROWSE OF THE
WRITE DATASET.
WRITE
WRITE IN THE CASE OF GDG DATASETS WITH RELATIVE GENERATION NUMBERS OR
WRITE PGENS SPECIFIED IN THE DATASET NAME, THE MOST RECENT GENERATION
WRITE WILL BE EDITED.
WRITE
WRITE THE STANDARD EDIT/BROWSE CONVENTIONS AND COMMANDS ARE AVAILABLE IN
WRITE THE RESULTING EDIT/BROWSE SESSION.
WRITE
WRITE *** END OF HELP *** NO PROCESSING PERFORMED ***


EXIT
            


Documentation


 This utility allows you to VIEW (i.e. ISPF EDIT if possible or ISPF BROWSE if
 EDIT is not possible) a dataset without having to type in the dataset name.
 For example, you are editing some JCL (since VIEW is an EDIT MACRO, it only
 works in an edit session), and you need to see the sort cards for a sort step
 but the cards are in a dataset.  You simply place your cursor on the first
 character of the dataset name and press a PF key that you have assigned the
 value "VIEW" to.  You will be taken into an edit session of that dataset if it
 is editable (i.e. within a valid LCREL range), or a browse session if it is not
 editable.  When you "END" or "CANCEL" out of the session, you will be returned
 to the original file that you were editing.
            


Leave a Reply

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