Professional Documents
Culture Documents
CLIST
Objectives
Understand CLIST programs and
procedures
Create & Execute new CLIST programs
Use In-Built functions
Understanding and practising the
Sample programs
Contents
What is CLIST?
Usage and Advantages
CLIST Statement Structures
Variables, Operators and Expressions
Creation & Execution
PROC Statement
In-built functions
Control Statements
Error handling
What is CLIST?
C-List stands for Command List
A CLIST is an online file containing
statements that can be executed in TSO in
the interactive mode
It is a set of TSO commands,
subcommands and CLIST statements that
have been arranged in a executable
sequence in a dataset
Contd
High Level Interpretive Language
Usage of CLIST
Simple execution of Multiple operations
Conditional execution of operations
Repetitive execution of same operations
Execution with parameter and variables
Interaction with end users
Simple arithmetic and logical operations
Error and interrupt detection
Advantages
minimizes typing and hence the typing
errors
lengthy commands can be stored and
executed when required
reduces the risk of executing commands
out of sequence
Contd..
Offers lot of flexibility
Interaction with Terminal User
Tolerance of errors and error
handling capacity
Write and Execute - need not
compile for load module creation
CLIST Statements
Each line in a CLIST procedure is a
statement
All CLIST statements must begin with
either a CLIST command or TSO
or subcommand
Statement structure
WRITENR
COMMAND
SET
OPERAND
COMMAND
IF
COMMAND
OPERAND
COMMAND
COMMAND
OPERAND
OPERAND
Syntax rules
Separators (space, comma and TAB)
Continuation Symbols ( + , -)
Uppercase letters
Comments /* This is a comment
Any TSO/CLIST commands can be labeled.
Labels can consists of :
Alphanumeric characters(A-Z,0-9,#,$,@,-)
Must begin with alphabet
Ex:
label1: IF A=
Variables
Two kinds of variables
User-defined
System-defined
Expression
Is a string in a CLIST statement that contains
optional
Arithmetic operators
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponentiation
// Remainder
Priority of operators
Creation of CLIST
CLIST Dataset Characteristics
Execution of CLIST
EXPLICIT EXECUTION
Execution of CLIST
IMPLICIT EXECUTION
Defining Variables
To define variables and assign specific
values
Use SET
Use READ to get Users response
Use PROC statement to get values from the
parameters passed to the CLIST
eg: SET NAME = AETNA (no quotes)
SET CI = &P * &N * &R
PROC Statement
Values can be passed in the EXEC
statement
All the values passed in the exec
statements should be declared in PROC
statement.
For this both Positional and key word
parameters can be used.
Positional parameters
EXEC (TEST) 100 ABC
PROC 2 NUMB SEQ
2 -- Number of Positional parameters
NUMB 100
SEQ ABC
A positional parameter cannot accept a null
value for a variable and it will prompt the user to
enter a valid value for the variable
Keyword parameters
EXEC NAME(RAM) AGE(28)
PROC NAME(AAA) AGE(00)
Name = Ram
Age =28
Default values for name and age are AAA
and 00 respectively
A keyword parameter can be set to null by
setting the variable with a blank bracket()
either in PROC or EXEC
WRITENR text
READ variables
Sample CLIST
WRITE A TRIAL CLIST
WRITE ENTER YOUR FIRST NAME
READ NAME
WRITE YOUR NAME IS &NAME
WRITE ENTER YOUR AGE
READ
WRITE &SYSDVAL IS YOUR AGE
Contd
Information about User :
Built-in Functions
These are some built in functions which will
perform the predefined functions when given the
required parameters
Sample - 1
WRITE ENTER THE STRING
READ &NAME
WRITE ENTER THE NUMBER OF CHARACTERS TO
EXTRACT
READ &NUM
WRITE NO OF CHAR IN GIVEN STRING IS
&LENGTH(&NAME)
WRITE THE EXTRACTED STRING IS
&SUBSTR(1:&NUM,&NAME)
WRITE THE DATATYPE OF THIS STRING IS
&DATATYPE(&SUBSTR(1:&NUM,&NAME))
Output is ..
The number of characters in the given is
7
The extracted string is IN
Sample - 2
WRITE ENTER THE DSN NAME THAT IS TO BE
CHECKED
READ &DSN
SET RES = OK
IF &SYSDSN(&DSN) EQ &RES THEN +
WRITE YES, THE DSN EXISTS
ELSE +
WRITE NO, THE DSN DOESN'T EXIST
This is to check whether the entered dsn name exists or
not
Nested CLISTS
A CLIST may have an EXEC
statement to execute another
CLIST. This subordinate CLIST
can also include EXEC statement
to invoke CLISTS on an even
lower level. These are referred to
as Nested CLISTS
/* MAIN PGM
GLOBAL VAR1 VAR2 VAR3
WRITE IN MAIN PROGRAM
WRITE ENTER THE FIRST NUMBER
READ VAR1
EXEC 'G21198.TEST.SRCLIB(LINK1)'
SET &VAR3 = &VAR1 + &VAR2
WRITE IN MAIN PROGRAM
WRITE THE RESULT IS &VAR3
/* LINK PGM
GLOBAL VAR1 VAR3
WRITE IN LINK1
WRITE ENTER THE SECOND NUMBER
READ VAR3
EXIT
IF Condition.
IF <cond> THEN <action> +
ELSE <action>
eg:
DO END Loop
Collect CLIST statements into a group of
logically related operations.
Format :DO [ variable = term1 TO term2 BY term3 ]
[WHILE condition ]
[UNTIL condition ]
END
WRITE DO LOOP
SET I = 1
DO WHILE &I LE 4
WRITE WHILE
SET &I = &I + 1
END
SET I = 1
DO UNTIL &I = 4
WRITE UNTIL
SET &I = &I + 1
END
DO &I = 1 TO 4 BY 1
WRITE INCREMENT
END
SELECT-END Loop
To test multiple conditions
executes the actions specified in the first
occurrence of a WHEN clause whose condition is
true.
Format :SELECT [ expression ]
WHEN ( condition1 ) +
action
WHEN ( condition2 ) +
action
OTHERWISE +
action
END
Example
WRITE ENTER CHOICE
READ C
SELECT (&C)
WHEN(y) WRITE YES
WHEN(n) WRITE NO
OTHERWISE WRITE INVALID
END
& in the select statement is a must. And in WHEN
clause no need for quotes even for characters
DISP=(NEW,CATLG)
EQUIVALENT CLIST:
ALLOC DA(&SYSPREF.PDS.NEW') RECFM(F B) TR DIR(1) +
Error handling
ERROR DO
IF &LASTCC < 4 THEN RETURN
ELSE +
DO
WRITE THERE IS AN ERROR
RETURN
END
END
SET &T = name
WRITE THE VALUE OF T IS &T
SET &T = &T + 1
WRITE THE PROGRAM CONTINUES WITH EXECUTION
WRITE THE VALUE OF T IS &T
Reference
Charles H. Rider , TSO/E CLIST The
Complete Tutorial and Desk Reference,
1992, QED Information Sciences, Inc.