Data Management Commands


There are several data management commands available for manipulating datasets and performing various operations on them. These commands are used to create, delete, rename, copy, and manipulate datasets in the TSO environment. Here are some commonly used data management commands in TSO -

ALLOCATE
Command
ALLOCATE (ALLOC) command used to dynamically defines and allocates a new dataset -
  • With or without an attribute list of DCB parameters.
  • With attributes copied from an existing dataset.
Syntax - ALLOC FILE(DDname) DA(dsname) [options]
Example - Allocate a new sequential dataset called MATEPK.TSO.TETPS.
ALLOC FI(REPORT)
   DA('MATEPK.TSO.TESTPS')
   NEW SP(1,1) CYL 
   LRECL(80) 
   RECFM(F B) 
   BLKSIZE(800) 
   VOL(DEVHD4)
LISTCAT
Command
The LISTCAT command lists the entries from master or user catalogs for the datasets or files. This information includes dataset attributes, volume information, and catalog entries.
Syntax -
LISTCAT ENTRY('entry-name')
or
LISTCAT CATALOG('catname')
        LIBRARY('lib_name')
        FILE('dname')
        [Options]
Example - List the information of the datasets starts with MATEPK.TSO.*
LISTC ENT('MATEPK.TSO.*')
LISTDS
Command
The LISTDS command is used to display the list of datasets that match a given pattern or criteria.
Syntax -
LISTDS [dataset-name(member-name)] [qualifiers] [options]
Example - List the matching PDS information with qualifier.
LISTDS 'MATEPK.COBOL.*'
This would display a list of all datasets that match the given pattern.
DELETE
Command
DELETE statement is used to delete one or more datasets or members from a partitioned dataset.
Syntax -
DELETE <datasetname> [membername] [options]
Example - delete a dataset.
DELETE 'MATEPK.ISPF.TESTPDS'
This would delete the MATEPK.ISPF.TESTPDS dataset from the system.
RENAME
Command
RENAME statement is used to rename a dataset or member in a partitioned dataset.
Syntax -
RENAME <oldname> <newname> [options]
Example - Rename dataset.
RENAME 'MATEPK.COBOL.SRCLIB' 'MATEPK.COBOL.SRCLIB1' 
This would rename MATEPK.COBOL.SRCLIB members to MATEPK.COBOL.SRCLIB1.
ATTRIB
Command
ATTRIB command is used to display or modify the attributes of a dataset or a member of a partitioned dataset.
Syntax -
ATTRIB [dataset-name(member-name)] [options]
Example - Change the dataset from PS to PDS.
ATTRIB 'MATEPK.ISPF.TESTPS' DSORG(PDS) 
This would change the dataset organization of MATEPK.COBOL.TEST to PDS.
LISTALC
Command
LISTALC command is used to display information about all datasets that are currently allocated by the system.
Syntax -
LISTALC [qualifiers] [options]
Example - List datasets allocated to job.
LISTALC JOBNAME(MYJOB)  
This would display a list of all datasets that are currently allocated by the MYJOB job.
FREE
Command
FREE command is used to deallocate a dataset that has been previously allocated.
Syntax -
FREE DATASET('dataset-name')
Example - Deallocate a dataset named MATEPK.TSO.TESTPS.
FREE DATASET('MATEPK.TSO.TESTPS')
This command will deallocate the MATEPK.TSO.TESTPS dataset, freeing up the system resources that were previously used by the dataset.
PRINT
Command
PRINTDS command is used to print the contents of a dataset to a printer or a display terminal. It is similar to the PRINT command.
Syntax -
PRINTDS DATASET(dataset-name) [options]
Example - Printing the dataset information.
PRINTDS DATASET('MATEPK.TSO.TESTPDS')
This would print MATEPK.TSO.TESTPDS information on the printer attached to the system.
COPY
Command
The COPY command is used to copy the contents of one or more datasets to another dataset or to a sequential file.
Syntax -
COPY FROM(source-dataset) TO(target-dataset) [options]
Example - Copy data from one PDS to another.
COPY FROM('MATEPK.TSO.TESTPDS') TO('MATEPK.TSO.TESTPDS1')
This would copy MATEPK.TSO.TESTPDS members to MATEPK.TSO.TESTPDS1.