z/OS DFSMS Using Data Sets
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example of Defining a VSAM Data Set

z/OS DFSMS Using Data Sets
SC23-6855-00

The following example shows a typical sequence of commands to create a catalog, define a data set (that is cataloged in the newly created catalog), load the data set with data, list the data set's catalog entry, and print the data set:
   //DEFINE   JOB ...
   //STEP1    EXEC PGM=IDCAMS
   //SYSPRINT DD SYSOUT=*
   //SYSIN    DD *
 
              DEFINE USERCATALOG (NAME (USERCATX) ICFCATALOG CYLINDERS(15 5) -
                     VOLUMES(VSER05)) DATA (CYLINDERS(3 1))
 
              IF LASTCC = 0 THEN -
                   DEFINE CLUSTER(NAME (EXAMPL1.KSDS) VOLUMES(VSER05)) -
                     DATA              (KILOBYTES (50 5))
   /*
   //STEP2    EXEC PGM=IDCAMS
   //SYSPRINT DD SYSOUT=*
   //SYSABEND DD SYSOUT=*
   //AMSDUMP  DD SYSOUT=*
   //INDSET4  DD DSNAME=SOURCE.DATA,DISP=OLD,
   //       VOL=SER=VSER02,UNIT=3380
   //SYSIN    DD *
 
        REPRO INFILE(INDSET4) OUTDATASET(EXAMPL1.KSDS)
 
        IF LASTCC = 0 THEN -
            LISTCAT ENTRIES(EXAMPL1.KSDS)
 
       IF LASTCC = 0 THEN -
            PRINT INDATASET(EXAMPL1.KSDS)
   /*
The following access method services commands are used in this example:
Command Purpose
DEFINE USERCATALOG Create the catalog
DEFINE CLUSTER Define the data set
REPRO Load the data set
LISTCAT List the catalog entry
PRINT Print the data set

See Using Job Control Language for VSAM for examples of creating VSAM data sets through JCL. See z/OS DFSMS Access Method Services Commands for more details and examples of these or other access method services commands.

The first DEFINE command defines a user catalog named USERCATX. The USERCATALOG keyword specifies that a user catalog is to be defined. The command's parameters follow.
Parameter Purpose
NAME NAME is required and names the catalog being defined.
ICFCATALOG Specifies the catalog format.
CYLINDERS Specifies the amount of space to be allocated from the volume's available space. If it is specified for a system-managed catalog, it overrides the DATACLAS space specification. A space parameter is required.
VOLUMES Specifies the volume to contain the catalog.

If the catalog is system-managed, then the system picks the volume. SMS ignores the value that is specified in the VOLUMES parameter.

However, if the catalog belongs to a storage class with guaranteed space, SMS selects the volume that you specify in the VOLUMES parameter. You also can write an ACS routine that uses the volume specified in the VOLUMES parameter to select a storage class.

DATA DATA is required when attributes are to be explicitly specified for the data component of the cluster.
CYLINDERS Specifies the amount of space allocated for the data component. A space parameter is required.
The second DEFINE command defines a key-sequenced data set named EXAMPL1.KSDS. The command's parameters are:
Parameters Purpose
CLUSTER The CLUSTER keyword is required, and specifies that a cluster is to be defined. The CLUSTER keyword is followed by the parameters specified for the whole clusters, and, optionally, by the parameters specified separately for the data and index components.
NAME NAME is required and specifies the cluster being defined.
VOLUMES Specifies the volumes that a cluster's components are allocated space. You can specify up to 59 volumes per cluster for system-managed clusters.
DATA DATA is required when parameters are explicitly specified for the data component of the cluster.
KILOBYTES Specifies the amount of space allocated for the data component.
The REPRO command here loads the VSAM key-sequenced data set named EXAMPL1.KSDS from an existing data set called SOURCE.DATA (that is described by the INDSET4 DD statement). The command's parameters are:
Parameter Purpose
INFILE Identifies the data set containing the source data. The ddname of the DD statement for this data set must match the name specified on this parameter.
OUTDATASET Identifies the name of the data set to be loaded. Access method services dynamically allocates the data set. The data set is cataloged in the master catalog.

Because the cluster component is not password protected, a password is not required.

If the REPRO operation is successful, the data set's catalog entry is listed, and the contents of the data set just loaded are printed.
Command Purpose
LISTCAT Lists catalog entries. The ENTRIES parameter identifies the names of the entries to be listed.
PRINT Prints the contents of a data set. The INDATASET parameter is required and identifies the name of the data set to be printed. Access method services dynamically allocates the data set. The data set is cataloged in the master catalog. No password is required because the cluster component is not password protected.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014