Mainframe Utility: CONTENTS

Return to Mainframe Utilities Page

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
/******************************************************************/
/* UTILITY: CONTENTS                                              */
/* AUTHOR: DAVID LEIGH                                            */
/* FUNCTION: INSERT MESSAGE OR DATA LINES OF THE CONTENTS OF A    */
/*           FILE WHICH YOU HAVE YOUR CURSOR PLACED ON AFTER THE  */
/*           LINE CONTAINING THE NAME OF THE FILE.                */
/******************************************************************/

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 &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 ISPEXEC VGET ZEROGEN SHARED
        SET DSN = &STR(&ZEROGEN)
    END

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 ISPEXEC VGET ZEROGEN SHARED
        SET DSN = &STR(&ZEROGEN)
    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 ISPEXEC VGET ZEROGEN SHARED
        SET DSN = &STR(&ZEROGEN)
    END

LISTDSI '&DSN'
IF &LASTCC = 4 AND &SYSREASON = 12 AND &SYSDSORG = VS THEN +
    DO
        SET ZEDSMSG = &STR(VSAM NOT SUPPORTED)
        SET ZEDLMSG = &STR("&DSN" IS A VSAM DATASET AND VSAM IS NOT +
                           SUPPORTED BY THE "CONTENTS" UTILITY)
        SET XMSG = &STR(UTLZ001)
        GOTO FINAL
    END

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

FREE DD(TEMPDD)
ALLOC DD(TEMPDD) DSN('&DSN') SHR KEEP

ERROR DO
    SET ERRCC = &LASTCC
    SELECT (&ERRCC)
        WHEN (4) RETURN
        WHEN (400) DO
            SET EOF = YES
            RETURN
        END
        OTHERWISE DO
            ERROR OFF
            WRITE *** ERROR CC: &ERRCC OCCURRED READING A FILE ***
            CLOSFILE TEMPDD
            FREE DD(TEMPDD)
            EXIT
        END
    END
END

IF &STR(&OPT) = WRITE THEN SET LINE =
ELSE SET LINE = MSGLINE
ISREDIT LABEL .ZCSR = .CURR
ISREDIT SEEK NEXT P'=' 1
IF &LASTCC > 0 THEN SET LABEL = &STR(.ZLAST)
ELSE SET LABEL = &STR(.ZCSR)

SET SWITCH = OFF
SET EOF = NO
OPENFILE TEMPDD
GETFILE TEMPDD

DO WHILE &EOF = NO
    ISREDIT LINE_BEFORE &LABEL = &LINE (TEMPDD)
    GETFILE TEMPDD
END

ERROR OFF
CLOSFILE TEMPDD
FREE DD(TEMPDD)

FINAL: +
ISREDIT CURSOR = &LN &CL

ISPEXEC SETMSG MSG(&XMSG)

EXIT

HELPSEC: +
CLEAR
WRITE *** HELP FOR EDIT MACRO 'CONTENTS' ***
WRITE
WRITE THE CONTENTS EDIT MACRO ALLOWS THE USER TO TYPE CONTENTS 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 'CONTENTS', 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 ===> CONTENTS
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


 The CONTENTS edit macro works similarly to the VIEW edit macro.  Type the
 command CONTENTS on the command line in an edit session, place the cursor on
 the beginning of a dataset name, and press .  CONTENTS then parses the
 line and extracts the dataset name, reads the dataset sequentially, and places
 the data from the dataset into the datasey being edited.

 The datalines from the target dataset are, by default, inserted as edit
 "message lines" (not real data).  In ISPF 3.0 and higher, these lines can be
 made into data lines with the MD line command.  You can, however, specify the
 parameter WRITE when invoking CONTENTS to insert the contents of the file as
 actual data lines.

 The obvious application for CONTENTS comes in creating some test JCL.  For
 instance, if you are editing some JCL which you've copied from production, and
 it invokes IDCAMS, there will be some SYSIN cards associated with it.  If the
 SYSIN cards are in another dataset and do a DELETE/DEFINE on a production VSAM
 dataset, you may want to do the same DELETE/DEFINE on a test dataset instead.
 What you would do is type CONTENTS WRITE on the command line, place your cursor
 on the first position of the SYSIN dataset name, and press .  The
 contents of that file are then inserted into your JCL.  You can make your
 changes and invoke the SYSIN cards in-stream instead of in a dataset name.
            


Leave a Reply

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