CLIST, MVS38J, Tips, TSO

Repeating CLIST Logic in MVS38J

Overview

There are times when the same CLIST logic is repeatedly applied where the only varying item may be one or two command statements and/or variable settings. 

Instead of repeating the same logic, take advantage of CLIST variable concatenation and substitution by using variables for the varying arguments in a command while using a loop control to execute the main common (repeating) logic. This results in rendering the original repeating logic in a shorter and easier-to-read CLIST!

This concept is best demonstrated by using an example comprised of PDS allocations with differing data set names and attributes.

The original CLIST contains repetitive logic blocks and the revised CLIST contains streamlined and consolidated logic.

Original CLIST

The original CLIST allocates several partitioned data sets, if not present on system, using TSO ATTR and ALLOC commands in blocks. The ATTR and FILE names are immediately FREE-ed, serving as temporary names. In essence, each block in mostly duplicate except for data set name and attributes.

PROC 0

/********************************************************************/
/*                                                                  */
/*    CLIST: C$ALDS0                                                */
/*                                                                  */
/* Author: Larry Belmontes Jr.                                      */
/*         https://ShareABitofIT.net/repeating-CLIST-logic-in-MVS38J*/
/*         Copyright (C) 2022  Larry Belmontes, Jr.                 */
/*                                                                  */
/*                                                                  */
/* Description:                                                     */
/* ---------------------------------------------------------------  */
/* CLIST to allocate ISPF user datasets.                            */
/*                                                                  */
/*                                                                  */
/* Messages:                                                        */
/* ---------------------------------------------------------------  */
/* None.                                                            */
/*                                                                  */
/*                                                                  */
/* Panels:                                                          */
/* ---------------------------------------------------------------  */
/* None.                                                            */
/*                                                                  */
/*                                                                  */
/* Return Codes:                                                    */
/* ---------------------------------------------------------------  */
/* None.                                                            */
/*                                                                  */
/*                                                                  */
/* Programs / Commands:                                             */
/* ---------------------------------------------------------------  */
/* SYSDSN   TSO SYSDSN check for DSN command                        */
/* FREE     TSO Free command                                        */
/* ALLOC    TSO Allocate command                                    */
/* ATTR     TSO Attribute command                                   */
/*                                                                  */
/*                                                                  */
/* Command Syntax:                                                  */
/* ---------------------------------------------------------------  */
/* Command:                                                         */
/* C$ALDS0                                                          */
/*                                                                  */
/* Parameters:                                                      */
/* None                                                             */
/*                                                                  */
/*                                                                  */
/* Using DEBUG:                                                     */
/* ---------------------------------------------------------------  */
/*                                                                  */
/*  Not applicable.                                                 */
/*                                                                  */
/*                                                                  */
/* Disclaimer:                                                      */
/* ================================================================ */
/*                                                                  */
/*    No guarantee; No warranty; Install / Use at your own risk.    */
/*                                                                  */
/*    This software is provided "AS IS" and without any expressed   */
/* or implied warranties, including, without limitation, the        */
/* implied warranties of merchantability and fitness for a          */
/* particular purpose.                                              */
/*                                                                  */
/*    The author requests keeping authors name intact in any        */
/* modified versions.                                               */
/*                                                                  */
/*    In addition, the author requests readers to submit any        */
/* code modifications / enhancements and associated comments        */
/* for consideration into a subsequent release (giving credit       */
/* to contributor(s)) thus, improving overall functionality         */
/* and further benefiting the MVS 3.8J hobbyist public domain       */
/* community.                                                       */
/*                                                                  */
/*                                                                  */
/*                                                                  */
/*                                                                  */
/* Change History:                                                  */
/* ================================================================ */
/* MM/DD/CCYY VERSION  NAME / DESCRIPTION                           */
/* ---------- -------  -------------------------------------------- */
/* 10/03/2022 0.9.00   Larry Belmontes Jr.                          */
/*                     - Initial version released to MVS 3.8J       */
/*                       hobbyist public domain                     */
/*                                                                  */
/********************************************************************/


/**********************************************************************/
/*   CREATE USER DYNAMIC ISPF PANEL LIBRARY                           */
/*   TO BE ALLOCATED LATER AS PART OF ISPPLIB                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..DYN.ISPPLIB                                      
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPDYNP) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(3 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE FI(ISPDYNP)                                                    
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF PROFILE DATASET                                 */
/*   TO BE ALLOCATED LATER AS PART OF ISPPROF                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISP.PROF                                         
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPPROF) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(10) SP(1 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE FI(ISPPROF)                                                    
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF CLIST DATASET                                   */
/*   TO BE ALLOCATED LATER AS PART OF ISPCLIB                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISPCLIB                                          
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPCLIB)                                                     
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPCLIB) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(5 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPCLIB)                                                     
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF MESSAGE DATASET                                 */
/*   TO BE ALLOCATED LATER AS PART OF ISPSLIB                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISPMLIB                                          
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPMLIB)                                                     
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPMLIB) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(5 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPMLIB)                                                     
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF LOAD DATASET                                    */
/*   TO BE ALLOCATED LATER AS PART OF ISPLLIB                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISPLLIB                                          
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPLLIB)                                                     
    ATTR PROFATTR RECFM(U)           BLKSIZE(19069)                     
    ALLOC F(ISPLLIB) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(5 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPLLIB)                                                     
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF PANEL DATASET                                   */
/*   TO BE ALLOCATED LATER AS PART OF ISPSLIB                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISPPLIB                                          
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPPLIB)                                                     
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPPLIB) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(5 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPPLIB)                                                     
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF SKELETON DATASET                                */
/*   TO BE ALLOCATED LATER AS PART OF ISPSLIB                         */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISPSLIB                                          
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPSLIB)                                                     
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPSLIB) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(5 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPSLIB)                                                     
  END                                                                   
                                                                        
/**********************************************************************/
/*   CREATE USER ISPF TABLE OUTPUT DATASET                            */
/*   TO BE ALLOCATED LATER AS PART OF ISPTTABL                        */
/**********************************************************************/
SET DSNAME0 = &SYSUID..ISPTLIB                                          
IF &SYSDSN('&DSNAME0') = OK THEN +                                      
  DO                                                                    
    WRITE     FOUND... => &DSNAME0                                      
  END                                                                   
ELSE +                                                                  
  DO                                                                    
    WRITE     CREATED... => &DSNAME0                                    
    CONTROL MSG                                                         
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPTABL)                                                     
    ATTR PROFATTR RECFM(F B) LRECL(80) BLKSIZE(3120)                    
    ALLOC F(ISPTABL) DA('&DSNAME0') NEW +                               
       USING(PROFATTR) DIR(40) SP(5 1) CYL                              
    CONTROL NOMSG                                                       
    FREE ATTR(PROFATTR)                                                 
    FREE F(ISPTABL)                                                     
  END                                                                   
                                                                        

Revised CLIST

The revised CLIST allocates partitioned data sets, if not present on system, by using a list of data set variable names (e.g. DSNAMEx).

After declaring number of data sets (CMD0) and associated data set attributes (DSNAMEx, DSATTRx, DSALOCx), a DO-WHILE statements executes ‘spinning through’ each data set allocation as depicted in the bottom half of the below CLIST.

PROC 0

/********************************************************************/
/*                                                                  */
/*    CLIST: C$ALDS0R                                               */
/*                                                                  */
/* Author: Larry Belmontes Jr.                                      */
/*         https://ShareABitofIT.net/repeating-CLIST-logic-in-MVS38J*/
/*         Copyright (C) 2022  Larry Belmontes, Jr.                 */
/*                                                                  */
/*                                                                  */
/* Description:                                                     */
/* ---------------------------------------------------------------  */
/* CLIST to allocate ISPF user datasets.                            */
/*                                                                  */
/*                                                                  */
/* Messages:                                                        */
/* ---------------------------------------------------------------  */
/* None.                                                            */
/*                                                                  */
/*                                                                  */
/* Panels:                                                          */
/* ---------------------------------------------------------------  */
/* None.                                                            */
/*                                                                  */
/*                                                                  */
/* Return Codes:                                                    */
/* ---------------------------------------------------------------  */
/* None.                                                            */
/*                                                                  */
/*                                                                  */
/* Programs / Commands:                                             */
/* ---------------------------------------------------------------  */
/* SYSDSN   TSO SYSDSN check for DSN command                        */
/* FREE     TSO Free command                                        */
/* ALLOC    TSO Allocate command                                    */
/* ATTR     TSO Attribute command                                   */
/*                                                                  */
/*                                                                  */
/* Command Syntax:                                                  */
/* ---------------------------------------------------------------  */
/* Command:                                                         */
/* C$ALDS0R                                                         */
/*                                                                  */
/* Parameters:                                                      */
/* None                                                             */
/*                                                                  */
/*                                                                  */
/* Using DEBUG:                                                     */
/* ---------------------------------------------------------------  */
/*                                                                  */
/*  Not applicable.                                                 */
/*                                                                  */
/*                                                                  */
/* Disclaimer:                                                      */
/* ================================================================ */
/*                                                                  */
/*    No guarantee; No warranty; Install / Use at your own risk.    */
/*                                                                  */
/*    This software is provided "AS IS" and without any expressed   */
/* or implied warranties, including, without limitation, the        */
/* implied warranties of merchantability and fitness for a          */
/* particular purpose.                                              */
/*                                                                  */
/*    The author requests keeping authors name intact in any        */
/* modified versions.                                               */
/*                                                                  */
/*    In addition, the author requests readers to submit any        */
/* code modifications / enhancements and associated comments        */
/* for consideration into a subsequent release (giving credit       */
/* to contributor(s)) thus, improving overall functionality         */
/* and further benefiting the MVS 3.8J hobbyist public domain       */
/* community.                                                       */
/*                                                                  */
/*                                                                  */
/*                                                                  */
/*                                                                  */
/* Change History:                                                  */
/* ================================================================ */
/* MM/DD/CCYY VERSION  NAME / DESCRIPTION                           */
/* ---------- -------  -------------------------------------------- */
/* 10/03/2022 0.9.00   Larry Belmontes Jr.                          */
/*                     - Initial version released to MVS 3.8J       */
/*                       hobbyist public domain                     */
/*                                                                  */
/********************************************************************/

/**********************************************************************/
/*   CREATE USER DATASETS IF NOT PRESENT ON SYSTEM                    */
/*   TO BE ALLOCATED LATER...                                         */
/**********************************************************************/
FREE ATTR(TMPATTR)                                                      
FREE FI(TMPFILE)                                                        
                                                                        
/**********************************************************************/
/*   VARIABLES CONTAINING ALLOCATION ARGUMENTS                        */
/*--------------------------------------------------------------------*/
/*   CMD0    -NUMBER OF DATASETS TO BE CREATED                        */
/*   DSNAMEX -DATA SET NAME                                           */
/*   DSATTRX -DATA SET ATTRIBUTES                                     */
/*   DSALOCX -DATA SET ALLOCATION ATTRIBUTES                          */
/**********************************************************************/
SET CMD0 = 8                                                            
/*   CREATE USER DYNAMIC ISPF PANEL LIBRARY                           */
SET DSNAME1 = &SYSUID..DYN.ISPPLIB                                      
SET DSATTR1 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC1 = &STR(NEW DIR(40) SP(3 1) CYL)                             
/*   CREATE USER ISPF PROFILE DATASET                                 */
SET DSNAME2 = &SYSUID..ISP.PROF                                         
SET DSATTR2 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC2 = &STR(NEW DIR(10) SP(1 1) CYL)                             
/*   CREATE USER ISPF CLIST DATASET                                   */
SET DSNAME3 = &SYSUID..ISPCLIB                                          
SET DSATTR3 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC3 = &STR(NEW DIR(40) SP(5 1) CYL)                             
/*   CREATE USER ISPF MESSAGE DATASET                                 */
SET DSNAME4 = &SYSUID..ISPMLIB                                          
SET DSATTR4 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC4 = &STR(NEW DIR(40) SP(5 1) CYL)                             
/*   CREATE USER ISPF LOAD DATASET                                    */
SET DSNAME5 = &SYSUID..ISPLLIB                                          
SET DSATTR5 = &STR(RECFM(U) BLKSIZE(19069))                             
SET DSALOC5 = &STR(NEW DIR(40) SP(5 1) CYL)                             
/*   CREATE USER ISPF PANEL DATASET                                   */
SET DSNAME6 = &SYSUID..ISPPLIB                                          
SET DSATTR6 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC6 = &STR(NEW DIR(40) SP(5 1) CYL)                             
/*   CREATE USER ISPF SKELETON DATASET                                */
SET DSNAME7 = &SYSUID..ISPSLIB                                          
SET DSATTR7 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC7 = &STR(NEW DIR(40) SP(5 1) CYL)                             
/*   CREATE USER ISPF TABLE OUTPUT DATASET                            */
SET DSNAME8 = &SYSUID..ISPTLIB                                          
SET DSATTR8 = &STR(RECFM(F B) LRECL(80) BLKSIZE(3120))                  
SET DSALOC8 = &STR(NEW DIR(40) SP(5 1) CYL)                             
                                                                        
                                                                        
/**********************************************************************/
/*   CREATE USER DATASETS IF NOT PRESENT ON SYSTEM                    */
/*   BY ITERATING THROUGH EACH DSN,ATRB,ALCSP                         */
/*   PER CMD0 TIMES.                                                  */
/**********************************************************************/
SET I = 1                                                               
SET &DSN = &STR(&&DSNAME)                                               
SET &ATRB = &STR(&&DSATTR)                                              
SET &ALCSP = &STR(&&DSALOC)                                             
DO WHILE &I <= &CMD0                                                    
  IF &SYSDSN('&DSN&I') = OK THEN +                                      
    DO                                                                  
      WRITE     FOUND... => &I.. &DSN&I                                 
    END                                                                 
  ELSE +                                                                
    DO                                                                  
      CONTROL MSG                                                       
      ATTR TMPATTR &ATRB&I                                             
      ALLOC F(TMPFILE) DA('&DSN&I') USING(TMPATTR) +                    
         &ALCSP&I                                                       
      CONTROL NOMSG                                                     
      FREE ATTR(TMPATTR)                                                
      FREE FI(TMPFILE)                                                  
      WRITE     CREATED... => &I.. &DSN&I                               
    END                                                                 
  SET I = &I + 1 
END              

Note, the CLIST contains less statement content while the allocation logic is consolidated under 
loop control.

- Declaration variables are highlighted in white.
- Loop control is highlighted in red.
- Data set variables used for command execution are highlighted in green.
- Enabling statements that facilitate command variance are highlighted in yellow.

- As the DO-WHILE iterates from 1 to number of data sets (&CMD0),
  &DSN&I   expands to  &DSNAME1, &DSNAME2, ... followed by variable substitution
  &ATRB&I  expands to  &DSATTR1, &DSATTR2, ... followed by variable substitution
  &ALCSP&I expands to  &DSALOC1, &DSALOC2, ... followed by variable substitution
  
  

Software Disclaimer

No guarantee; No warranty; Use at your own risk.

This software is provided “AS IS” and without any expressed or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.

The author requests keeping authors name intact to any modified versions.

In addition, the author requests readers to submit any code modifications / enhancements and/or associated comments for consideration into a subsequent release (giving credit to contributors) thus, improving overall functionality and further benefiting the MVS 3.8J hobbyist public domain community.

In closing…

This is one approach to streamline replicative logic in a CLIST that I’ve used over the years.

Just as with any solution, other derivatives may exist. The above example was developed and tested with the public domain MVS 3.8J OS.

Comments or feedback? Use the comment box below or the contact us link on the menu bar.

Have fun!

Tagged ,

Leave a Reply

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


CAPTCHA Image
Reload Image

This site uses Akismet to reduce spam. Learn how your comment data is processed.