Tuesday, November 18, 2008

TSO Commands, TSO Line Mode Commands - TSO Native Mode Commands Tutorial

TSO - Time Sharing Option of IBM's mainframe operating system MVS (also called OS/390 or Z/OS). TSO is an on-line interactive program development system that gives access to the same files as with batch (JCL) jobs. TSO is used to:
create, maintain and compile programs
create, maintain and submit JCL to run jobs
inspect the printed or displayed output of JCL jobs
interactively test both batch and on-line programs Practically every installation uses ISPF or PDF to assist in program development. ISPF/PDF is a full-screen, menu driven system similar in concept to Windows 3. ISPF executes inside of TSO exactly as Windows 3 executed inside of DOS. DOS was always there and you could always do DOS commands before and after going into Windows 3. Similarly, you can execute TSO commands before and after you go into ISPF. TSO Line Mode Commands are sometimes called Native TSO Commands, or just plain TSO commands. They are the things you can't always do with ISPF or PDF. Running TSO commands while in ISPF is done in ISPF option 6, Command Shell, (like opening a DOS window in Windows 95 and later) or by prefixing the command with TSO and typing it on the command line of any ISPF screen. With TSO commands, you can delete files, create or allocate files, rename files. You can control migration and recall of files, although you often see ISPF screens which do that. You can SEND messages to other TSO users. You can connect files to file handles (DDNAMES) in order to read or write to the files in a program, REXX exec or CLIST. You need to know TSO line mode commands if you are going to master REXX or CLIST, since both REXX and CLIST can execute these TSO line mode commands. You may print out this TSO command quick reference and use it at work. The TSO COPY command is not included because it suffers from several design and implementation errors.
var x = 0;
TSO Commands
TSO Manuals and Tutorials TSO/ISPF Dialogue Manager Book Just Enough ISPF to be Dangerous Comparison of REXX and CLIST REXX Reference Book
REXX Programming Book for TSO
Books on MVS, TSO, CLIST
These are TSO line mode commands. There is generally no ISPF screen that will do the same thing. For help on the commands,
- on any ISPF screen, type TSO HELP; (If you are outside of ISPF just type HELP)
choose a command, then type TSO HELP command-name.
or use Quick Reference by typing QW on any ISPF screen
then specify IBM as vendor
then search for TSO SYSHELP
There are 6 places you can execute TSO commands. Read the parts about continuing!
1. In a REXX program. Information about my book on REXX: http://www.theamericanprogrammer.com
The command must be enclosed in quotes (") or apostrophes (').
Quotes are preferred, because they conflict less
with the apostrophes that some TSO commands require.
Example of an ALLOCATE command in a REXX program:
"ALLOC DDN(INFILE) SHR REUSE DSN(MY.DATA)"
When there is a variable in the command you want REXX to process the variable.
Quotes prevent REXX from processing the variable.
Remove the variable from the quotes.
Example of an ALLOCATE with the dataset name in a variable.
Dataset_Name = "MY.DATA"
"ALLOC DDN(INFILE) SHR REUSE DSN("Dataset_Name")"
In a REXX program commands for ISPF are prefixed by ADDRESS ISPEXEC, for example:
ADDRESS ISPEXEC "SETMSG MSG(ISRZ001)"
Commands for ISPF editor are prefixed by ADDRESS ISREDIT, for example:
ADDRESS ISREDIT "CHANGE ALL DNS DSN"

Continuing. Break the command into two parts.
Enclose each part in quotes. End the first part with a comma.
EXAMPLE:
"ALLOC DDN(INFILE)SHR REUSE",
"DSN(MY.DATA)"
2. In a CLIST.
The command is entered into the CLIST as shown in the examples.
Example of an ALLOCATE command in a CLIST:
ALLOC DDN(INFILE) SHR REUSE DSN(MY.DATA)
When there is a variable in the command, put the variable
in the command and be sure it is prefixed with an ampersand (&).
Example of ALLOCATE in a CLIST with the dataset name in a variable:
SET &DATASET_NAME = MY.DATA
ALLOC DDN(INFILE) SHR REUSE DSN(&DATASET_NAME)

Continuing. Break the command into two parts. End the first part with a hyphen or +. The + causes leading spaces on the next line to be deleted..
EXAMPLE:
ALLOC DDN(INFILE) SHR REUSE -
DSN(&DATASET_NAME)

3. In ISPF Option 6.
Enter the command as shown in the examples
Example of an ALLOC command in ISPF Option 6:
ALLOC DSN(MY.DATA) SHR REUSE DDN(INFILE)

Continuing. Just keep typing. There’s room..

4. On any ISPF screen except Option 6.
Enter the command as shown in the examples, prefixed with "TSO".
Example of an ALLOCATE command in ISPF Option 6:
TSO ALLOC DDN(INFILE) SHR REUSE DSN(MY.DATA)

Continuing. You are out of luck. There’s not much room.

5. In line mode TSO, known as "Ready mode". I.E., you are not in ISPF.
Enter the command as shown in the examples
Example of an ALLOCATE command in line mode TSO.
ALLOC DDN(INFILE) SHR REUSE DSN(MY.DATA)

Continuing. Just keep typing. There’s room..

6. In a batch job where the program IKJEFT01 is executed, known as TSO in batch.
Enter the command as shown in the examples
Example of an ALLOCATE command in a batch job.
ALLOC DDN(INFILE) SHR REUSE DSN(MY.DATA)
Example in context:
//STEP1 EXEC PGM=IKJEFT01,DYNAMNBR=200
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
ALLOC DDN(INFILE) SHR REUSE DSN(MY.DATA)
/*
Continuing. There are only about 67 positions available
Break the command into two parts. End the first part with a hyphen.
EXAMPLE:
ALLOC DDN(INFILE) SHR REUSE -
DSN(MY.DATA)


Interacting with files:
Create a catalogued disk file/dataset
ALLOCATE with the NEW keyword
ALLOC DSN(dataset-name) NEW (continued)
SPACE(10 5) TRACKS
Create a catalogued disk library/pds
ALLOCATE with the NEW keyword and the DIR keyword
ALLOC DSN(library name) NEW (continued)
SPACE(10 5) TRACKS DIR(10)
Connect a catalogued disk file/ dataset to a program for use as input or output
ALLOCATE with the SHR or OLD keyword and the DDN keyword
ALLOC DDN(ddname) SHR REUSE DSN(dataset-name)
Connect a catalogued library member/pds member to a program for use as input or output
ALLOCATE with the SHR or OLD keyword and the DDN keyword
ALLOC DDN(ddname) SHR REUSE (continued)
DSN(library-name(member-name))
Note that the library must exist.
The member must exist if it is input.
The member will be created or overwritten, if it is output.
Connect a catalogued disk file/ dataset to a program for use as output, lengthening (append) the file
ALLOCATE with the MOD keyword and the DDN keyword
ALLOC DDN(ddname) MOD REUSE DSN(dataset-name)
Create a catalogued disk file/dataset, or library/ pds that has the same attributes as another
ALLOCATE with the LIKE keyword
ALLOC DSN(dataset-name) LIKE(other-dataset-name)
Notes about ALLOCATE:
REUSE means that the DDN(ddname) should be released
from any previous use and used for this ALLOCATE
SPACE(10 5) means that the system should allocate
10 units of space immediately, 5 units later (up to 15 times as needed)
DIR(10) means that the system should reserve 10 blocks of
space for the directory that will keep track of the members.
1 directory block keeps track of 5 members.
Remove the connection between a file and a program that has been established with ALLOCATE and the DDN keyword
FREE DDN(ddname)
Copy a file to one that exists already, overlaying it. (Allocate the output file first with ALLOC or ISPF 3.2)
REPRO INDATASET(‘input dataset name’) (continued)
OUTDATASET(‘output dataset name’)
Display the attributes of a file/dataset library/pds
LISTDS dataset-name or library
Display the attributes of a library/pds and list the member names
LISTDS library MEMBERS
Display the dataset names, library names, and DDNAMES currently in use in your TSO session.
LISTALC STATUS HISTORY SYSNAMES
Display catalog information about a specific dataset or library.
LISTCAT ENTRY(dataset name) ALL
List the names of datasets or libraries whose names begin with a specific high level qualifier.
LISTCAT LEVEL(high-level-qualifier)
Example:
LISTCAT LEVEL(USERID1)
Delete a dataset or library
DELETE dataset or library
Delete a library member (not the library)
DELETE library(member-name)
Rename a dataset or library
RENAME old-name new-name
Specify a REXX or CLIST library without having to do complicated allocations.
ALTLIB ACTIVATE APPLICATION(appl) DSN(appl-library)
Specify a REXX library
ALTLIB ACTIVATE APPLICATION(EXEC) DSN(rexx-library)
Specify a CLIST library
ALTLIB ACTIVATE APPLICATION(CLIST) DSN(clist-library)
Interacting with other users
Authorize access to your files with RACF.
PERMIT 'your-userid.**' ID(userid-to-authorize) ACCESS(READ)
or access(update)
userid-to-authorize may be * to mean all users
Transmit a message to a TSO user. Cancel the message if the user can’t receive messages or is logged off.
SEND 'the message' USER(the-userid)the-userid may be *, which means to yourself
Transmit a message to a TSO user. Wait until the user is able to receive the message.
SEND 'the message' USER(the-userid) WAIT
the-userid may be *, which means to yourself
Transmit a message to a TSO user. The message will be delivered at once if the user is logged on. It will be delivered when the user logs on, if the user is now logged off.
SEND 'the message' USER(the-userid) LOGON
the-userid may be *, which means to yourself
Transmit a message to the console operator
SEND 'the message'
Send a dataset to another user (TSO or CMS)
XMIT node.userid DSN(datasetname)
Send a library/pds member to another user (TSO or CMS)
XMIT node.userid DSN(libraryname(membername)) SEQ
Receive a dataset or library sent by another user with XMIT
RECEIVE

Interacting with TSO
Display messages sent to you while you were logged off
LISTBC
Display the current time, CPU time used, service units used, and date
TIME
Turn off prompting - commands asking you for missing or invalid information
PROFILE NOPROMPT
Find out if TSO is prefixing your logon userid to dataset names specified without apostrophes.
PROFILE
Make TSO prefix your logon userid to dataset names specified without apostrophes.
PROFILE PREFIX(your-userid) The default
Stop TSO from prefixing your logon userid to dataset names specified without apostrophes.
PROFILE NOPREFIX Not Recommended
Execute a program when you know which library it is on
CALL ‘library-name(program-name)’
Execute a program that is on an automatic search library ("the linklist")
CALL *(program-name)
You may also be able to execute a program by simply putting its name in quotes:
"IEBGENER"
This is not allowed at all companies.
Execute a REXX program or CLIST found on a library assigned to SYSPROC or SYSEXEC
"program-name" "parameters if any"
Execute a REXX program or CLIST that is not found on a library assigned to SYSEXEC
"EXEC ‘libry-name(member-name)’ ‘parameters if any.’ " EXEC
Execute a CLIST that is not found on a library assigned to SYSPROC
"EXEC ‘library-name(member-name)’ ‘parameters if any.’ "
Interacting with MVS Batch
Display current job status of jobs that you have submitted
STATUS
Cancel a job that you have submitted
CANCEL jobname(job-number)
Cancel a job that you have submitted and discard the printed output
CANCEL jobname(job-number) PURGE
Send JCL to MVS batch for processing I.E. spawn a detached process
SUBMIT dataset-name or library(member-name)
Interacting with the Hierachical Storage System (migrating)
Unmigrate a dataset or library that has been migrated
HRECALL dataset/library
Migrate a dataset or library I.E. send it to off-line storage, probably tape
and temporarily delete it from active disk storage
HMIGRATE dataset or library
Create a backup copy of a dataset or library (if installation authorizes)
HBACKDS dataset/library
Retrieve the most recent backup copy of a dataset or library that has been backed up
HRECOVER dataset-name
Retrieve the backup copy of a dataset or library that was created before the most recent one
HRECOVER dataset-name GENERATION(1)
Ask about your HRECOVER request.
HQUERY

Using ISPF services.
Information about my book on ISPF Dialogue manager http://www.theamericanprogrammer.com/programming/dmbook/html
Specify a library that contains components of an ISPF dialog.
LIBDEF component DATASET ID(library-name) UNCOND
for example:
LIBDEF ISPPLIB DATASET ID(MY.ISPPLIB) UNCOND
REXX Example:
ADDRESS ISPEXEC "LIBDEF ISPPLIB DATASET ID(MY.ISPPLIB) UNCOND "
Components are:
ISPPLIB Panel library
ISPSLIB File Tailoring Skeleton Library
ISPMLIB Message library
ISPFILE File Tailoring output library
ISPTLIB Table input
ISPTABL Table output
ISPLLIB Load module
Store variable information in TSO/ISPF for later use
VPUT (variable-name) PROFILE
REXX Example:
ADDRESS ISPEXEC "VPUT (variable-name) PROFILE"
Retrieve variable information from TSO/ISPF
VGET (variable-name)
REXX Example:
ADDRESS ISPEXEC "VGET (variable-name)"
Setting messages that will appear on ISPF screens.
REXX Example:
ZEDSMSG = "this is the short message"
ZEDLMSG = "this is the long message"
ADDRESS ISPEXEC "SETMSG MSG(ISRZ001)"
Executing a program when you don't know which library it is on
SELECT PGM(program-name)
REXX Example:
ADDRESS ISPEXEC "SELECT PGM(program-name)"
Prevent an ISPF error from kicking you out of your session. (Hides diagnostic messages)
CONTROL ERRORS RETURN
REXX Example:
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"


Old non-ISPF editor.
I will show this by an example. The line numbers on the left are for illustration only.
1 EDIT 'userid.TEST.CNTL(MODEL)' DATA OLD NONUM EMODE
2 TOP
3 CHANGE * 999 '@DSN' 'MY.DATA'
4 SUBMIT
5 END NOSAVE
Explanations by line.
Line 1. EDIT 'fully-qualified-dataset-name' DATA OLD NONUM EMODE
Please use a fully-qualified dataset name, with apostrophes.
Replace DATA with COBOL if it is a COBOL program.
OLD means that it exists already
NONUM means that the editor should ignore line numbers, if any.
NUM instead means that the editor should assume line numbers
EMODE means that the editor should not go into "input mode"
when the dataset contains no records
Input Mode is when the editor accepts no commands!
everything you type in is placed into the dataset as a new line.
You end Input Mode by pressing ENTER without typing anything.
Line 2.
TOP.
Position yourself at the top of data (important for the change command)
Line 3.
Change character strings on each line from current line position
(shown by *) to the end (shown by 999)
CHANGE * 999 'old string' 'new string'
Line 4.
Send the data you are editing (if it's JCL) to MVS batch for processing
I.E. spawn a detached process
SUBMIT
Line 5.
Exit without saving data in the name you started with
END NOSAVE
Other commands you might use.
Exit and save data in the name you started with
END SAVE
Save what you are editing with a specific name other than the one you started with
SAVE new-name REUSE
The above example in a REXX program. You must queue the commands. They will be executed after the REXX program ends. You may not put anything else into the queue since that will interfere with this.
QUEUE "EDIT 'userid.TEST.CNTL(MODEL)' DATA OLD NONUM EMODE"
QUEUE "TOP"
QUEUE "CHANGE * 999 '@DSN' 'MY.DATA' ALL"
QUEUE "SUBMIT
QUEUE "END NOSAVE"
The above example in a CLIST. There is no change from the example above. The CLIST will execute the commands line by line. After finishing the commands, control will remain in the CLIST.

Visit my web page to get other cheat sheets.
http://www.TheAmericanProgrammer.com/programming/justenuf.shtml
Rexx info: http://www.TheAmericanProgrammer.com/programming/
About this series.
Sometimes you need just enough information so that you can do something
- it gets you started when you don’t have time to learn everything.
Get all the others in the series at: Justenuf
Other Books for professionals:

REXX Reference
All REXX verbs, keywords, and built-in functions as found in MVS, VM/CMS and OS/2.
Order from MVS Training (800) 356 9093.MVS Training

The REXX Language on TSO
How to use REXX on TSO. Information, ordering at: REXX
ISPF Services: Using the Dialogue Manager with REXX
How to create ISPF panels on TSO. Examples in REXX. Information, ordering at:ISPF Services
You will find a large selection of mainframe books at: Books.
You’ll find manuals on TSO, JCL, REXX, COBOL, DB2 at: Manuals.

No comments: