Upload
suzeet1
View
222
Download
3
Embed Size (px)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 1/147
REXX Training
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 2/147
S E SSION 1
Introduction to REXX
REXX basics REXX Instructions
REXX Built-in Functions
REXX External functions REXX TSO/E External commands
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 3/147
S E SSION 2
Executing REXX in BATCH mode
Introduction to REXX Edit macros Examples on REXX Edit macros
File Tailoring
ISPF Tables REXX Quiz
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 4/147
What is REXX REXX after all ?
R R estructured EX EX tended eX X ecutor
language
Programming Language
Free format language
Issues commands to different Host
environments Has extensive mathematical capabilities
Suitable for beginners as well computer
professionals
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 5/147
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 6/147
W riting a simple REXX exec
An exec is nothing but a group of REXX statements in a
sequential dataset or a PDS member
The first statement of an exec should be µ /* REXX */ ¶,but
not in all cases
A simple exec (In a PDS member,MYFIRST)
/*REXX*/ /*REXX*/
SAY µThis is first REXX exec¶ SAY µThis is first REXX exec¶
EXIT EXIT
REXX is case insensitive
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 7/147
Executing a REXX exec Explicit execution from tso ready prompt
READY
EXEC µTATA.REXX.EXEC(MYFIRST)¶ EXEC
READY Implicit execution requires the PDS library to beconcatenated to either SYSEXEC or the SYSPROC systemDDNAME¶s.
READY
ALLOC DD(SYSEXEC) DSN(µTATA.REXX.EXEC¶) SHR REUSEREADY
%MYFIRST
From ISPF,one can execute it by issuing the following command atcommand prompt
TSO MYFIRST
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 8/147
Executing a REXX execA sequential dataset needs no allocation
It can only be executed using the explicit method or thelong form
From READY prompt,READY
EXEC µTATA.SEQ.EXEC¶ EXEC
READY
CTP LOGON ALLOCATION
In CTP main panel,
Select 0 --> CTP parms
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 9/147
REXX - Arithmetic operators+ Add
- Subtract
* Multiply
/ Divide
% Divide and return a whole number without aremainder
// Divide and return the remainder only
** Raise a number to a whole number power
-number Negate the number
+number Add the number to 0
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 10/147
REXX - Logical operators& AND(4 > 2) & (a = a) /* true, so result is 1 */(2 > 4) & (a = a) /* false, so result is 0 */
| Inclusive OR (4 > 2) | (5 = 3) /* at least one is true, so result is 1 *(2 > 4) | (5 = 3) /* neither one is true, so result is 0 */
&& Exclusive OR
(4 > 2) && (5 = 3) /* only one is true, so result is 1 */(4 > 2) && (5 = 5) /* both are true, so result is 0 */
Prefix \ Logical NOT\ 0 /* opposite of 0, so result is 1 */\ (4 > 2) /* opposite of true, so result is 0 */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 11/147
REXX - comparison operators== Strictly Equal
= Equal
\ == Not strictly equal
\ = Not equal> Greater than
< Less than
> < Greater than or less than (same as not equal)
> = Greater than or equal to
\ < Not less than
< = Less than or equal to
\ > Not greater than
Note: The not character, "¬", is synonymous with the backslash ("\").
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 12/147
REXX Symbols
A REXX symbol can consist of
A...Z uppercase alphabetic
a...z lowercase alphabetic0...9 numbers
@ # $ ¢ ? ! . _ special characters
Rules for valid REXX symbols are :
The first character cannot be 0 through 9 or a period (.)
The variable name cannot exceed 250 bytes
The variable name should not be RC, SIGL, or RESULT,
which are REXX special variables
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 13/147
REXX Special VariablesRC: RC stands for return code and is set every time acommand is issued.When a command ends without error, RCis usually set to 0. When a command ends in error, RC is setto whatever return code is assigned to that error.
SIGL: The SIGL special variable is used in connection with atransfer of control within an exec because of a function, or aSIGNAL or CALL instruction. When the language processor transfers control to another routine or another part of the exec,
it sets the SIGL special variable to the line number from whichthe transfer occurred.
RESULT : When an exec calls a subroutine ,the calling execreceives the value returned by the subroutine in the REXX
special variable RESULT
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 14/147
REXX Instructions
Cool Man! Cool Man!
Life Made Easy«Life Made Easy«
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 15/147
REXX InstructionsA line contains usually one instruction
Comma(µ,¶) is the continuation character
Semi-colon(µ;¶) is the instruction delimiter
Example :
say µThe quick fox jumps over¶,
µthe lazy brown dog¶; say µover¶
Output :The quick fox jumps over the lazy brown dog
over
Note that the comma operator adds a space
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 16/147
REXX Instructions - SAY To write a line of output to the TSO terminal
Syntax
SAY {expression}
Expression can be of any size and REXX will split it upaccording to line-width of the terminal
Expression can contain variables, literals and functions
Example /*REXX*/ /*REXX*/
name=µRoosevelt¶ name=µRoosevelt¶ say µWelcome to TSO µ namesay µWelcome to TSO µ name
exit exit
Output
Welcome to TSO Roosevelt
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 17/147
REXX instruction - PULL to read the input from the TSO terminal(When REXX datastack is empty)
Syntax : PULL var1 var2 var3«
Example :/*REXX*/
say µEnter your name :¶
pull name
say µGood morning µ name
exit
The output will beEnter your name :
Lincoln
Good morning LINCOLN
Note that PULL automatically converts input into
uppercase
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 18/147
REXX Instruction - UPP ER to translate the contents of a single or several variables touppercase
Syntax : UPPER var1 var2 var3 «
Example :
/*REXX*/
name=µKennedy¶
say µName is µ name
upper name
say µNow name is µ nameexit
Output
Name is Kennedy
Now name is KENNEDY
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 19/147
REXX Instruction - EX IT Used to unconditionally leave a program
Can optionally pass back a string to the caller
Syntax : EXIT {expression}
Example named PROG2
/*REXX*/
a=10
exit a*10 /* passes back string 100 to the caller */
When prog2 is called in an exec as x=prog2(),then x will
have the value 100
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 20/147
REXX Instruction - IF Used to conditionally execute a single REXX stmt or a
group of REXX statements
Syntax : If expression then stmt;
else stmt;
If expression is evaluated TRUE(1) then the THEN part is
performed and if FALSE(0) then the ELSE part is
performed.
A group of REXX statements can be grouped together by
using DO«END
Nested IF¶s are allowed in REXX.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 21/147
REXX Instructions - NOP
NOP stands for No-operation
Causes REXX to create No-operation condition
Only useful as a target of THEN or ELSE clause
Syntax : NOP;
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 22/147
REXX Instructions - IF Example/*REXX*/
say ¶Enter AM/PM :'
pull ampm
if ampm = 'AM' then say 'Good morning!!!'
else if ampm = 'PM' then say 'Good evening!!!'else NOP;
EXIT
Output :
Enter AM/PM :
AM
Good morning!!! When the input is blank or other than AM/PM , theinstruction that gets executed is NOPAlso note that the ELSE clause is not mandatory When the ELSE clause is removed ,the functionality of
the program will still be the same
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 23/147
REXX Instructions - DO Used to execute a group of REXX statements under the
control of an expression
Has several formats
The repetitive DO construct
DO 5 /* DO X=5 is the same */
say µhi there!!!¶
END
The rexx statements within DO..END will be executed five
times
Contd...
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 24/147
REXX Instructions - DO Do with loop counter
/*REXX*/
Do I = 1 to 7 by 2 /* 2 is the step value */
say I
End I /* optional to specify the variable */
The output will be
1
3
5
7
Contd...
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 25/147
REXX Instructions - DO Do..While construct
/*REXX*/
I=1
Do while I < 3
say I
I = I + 1
End
The output
1
2
Contd...
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 26/147
REXX Instructions - DO Do..Until construct
/*REXX*/
I=1
Do until I > 3
say I
I= I+ 1
End
The output will be
1
2
3
Contd...
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 27/147
REXX Instructions - DO The Do..Forever special construct
/*REXX*/
Do forever say µinfinite loop¶
end
The above exec results into an infinite loop
Enough care should be taken to check the exit criteria of
the loop, before executing the exec
The LEAVE instruction can be used to exit from the loop
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 28/147
REXX Instructions - L E AV E Causes REXX to stop executing the current DO-END loop andcontrol passes to the next statement after the END of the DO-END pair
Syntax : LEAVE {name}
Example
/*REXX*/
Do forever
Say µEnter the code :¶
Pull code
If code = µBYE¶ then Leave;
endExit
The above exec will prompt the user for a code until the user enters thecode µBYE¶.
The µname¶ will be used to exit from a particular loop in case of several nested do loops
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 29/147
REXX Instructions - IT ER AT E Used to restart execution in a DO loop
Syntax : ITERATE {name}
If name is not specified ,ITERATE will step the innermostactive loop
If name is specified,that particular loop is stepped
Example/*REXX*/
Do I = 1 to 3 by 1
If I = 2 then iterate I; /* name is not required */say µI = µ I
end
Output
I = 1
I = 3
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 30/147
REXX Instructions - S E L EC T Causes REXX to execute one of several different
instructions
Most used when one of the several paths must be followed
Example :/*REXX*/Say µEnter 1 for salad,2 for pizza :¶ pull choiceselect
when choice = 1 then say µHere is the salad¶when choice = 2 then say µHere is the pizza¶otherwise say µYou have opted nothing¶
End
When the input is anything other than 1 or 2 then thecontrol is transferred to OTHERWISE clause.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 31/147
REXX Instructions - INT ER P RE T Used to execute instructions that are built dynamically
Allows to build the REXX statements in an exec
Syntax : INTERPRET expression Example :/*REXX*/
out='say hi there!!!'
Interpret out
stmts='do 3; say 'loop'; end'
Interpret stmts
exit Output will be
HI THERE!!!
LOOP
LOOP
LOOP
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 32/147
REXX Instructions - NUM ER I C Sets controlling limits that govern how REXX evaluates
and reports the results of arithmetic operations
Syntax : NUMERIC DIGITS {expression}
This tells REXX how many significant digits to use when
calculating and printing results
Syntax : NUMERIC FORM { SCIENTIFIC | ENGINEERING }
This tells REXX how arithmetic values that must beexpressed in exponential notation will be presented
NUMERIC FUZZ {expression}
This determines how much two numbers can be different
from each other and still be considered equal by REXX
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 33/147
REXX Instructions - NUM ER I C Example/*REXX*/numeric digits 4numeric fuzz 1a=1000 b=1004if a = b then say equalelse say unequalexit
OutputEQUAL
Since the FUZZ value is 1,the rightmost is not consideredin the comparison. In the same example ,note that when B takes value 1005and numeric digit is 5 ,the output is UNEQUAL ,as REXXrounds off the value of B to 101,while eliminating its
rightmost digit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 34/147
REXX Instructions - NUM ER I C Numeric form scientific causes REXX to always place one
non-zero digit to the left of the decimal point
Numeric form engineering makes REXX use powers of ten
in exponential notation that are always a multiple of three
Example/*REXX*/
numeric digits 5
numeric form scientific
a=123.45 * 1e11say a form() /* 1.2345E+13 SCIENTIFIC */
numeric form engineering
a=123.45 * 1e11
say a form() /* 12.345E+12 ENGINEERING */
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 35/147
REXX Instructions - PA RS E Tells REXX how to assign data to one or more variables
PARSE NUMERIC name returns the current settings of numeric options DIGITS,FUZZ and FORM
PARSE PULL makes REXX get the string from the REXXdata stack.If the stack is empty,REXX will get the stringfrom the terminal
PARSE VALUE parses a string under the control of thetemplate
PARSE VALUE expression WITH template
PARSE VAR indicates that the string to be parsed is not aliteral but a variable
PARSE VERSION returns REXX interpreter level and thedate released
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 36/147
REXX Instructions - PA RS E Ex. parse value µNapolean the great¶ with w1 w2 w3
w1 = Napolean w2 = the w3 = great
parse value µNapolean the great¶ with w1 9 w2
w1 = µNapolean µ w2 = µthe great¶
parse value 'salt+water=brine' with w1 '+' w2 '=' w3
w1 = salt w2 = water w3 = brine
parse version vervar
say vervar
REXX370 3.48 01 May 1992
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 37/147
REXX Instructions - D ROP Used to return one or more REXX variables to their initial
or uninitialised state
Syntax : DROP name1 name2 name3«.;
Same variable can be dropped more than once
Examples
drop a /* Unassigns the variable a*/
drop z.5 /* Unassigns the stem variable z.5 */
drop d. /* Unassigns all the vars starting with d. */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 38/147
REXX Instructions - ADD RE SS To indicate the destination of non-rexx commands
Syntax ADDRESS destination
The destination could be any one of these
TSO - Routes commands to TSOISPEXEC - Routes commands to ISPF/PDF
ISREDIT - Routes commands to the ISPF Edit macro processor
Note : Other destinations exist,but beyond the scope of this
training Example :
Address tso µlista st¶ /* the destination is set */
µlistds(µtcs.rexx.exec¶) members¶ /* to TSO */
Address ispexec /* Dest. Changed and set */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 39/147
REXX Instructions - Procedure used to protect the variables in existence when the function
or subroutine is called
When a RETURN instruction is executed by the calledfunction or subroutine ,all variables saved by the
PROCEDURE instruction are restored to the state they were
in when saved
Syntax : PROCEDURE { EXPOSE name1 {name2}«}
name1, name2 are not protected from the subroutine.That is
they are exposed to the subroutine
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 40/147
REXX Instructions - ProcedureExample
/*REXX */
lines=2
pages=3call showlyns
say 'The line count is' lines ',the page count is' pages
/* 'say' above displays 10 for lines and 3 for pages */
exit
showlyns: procedure expose lines
lines=10;pages=1 /* sets caller's 'lines' variable */
/* but a local 'pages' variable */
return
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 41/147
REXX Instructions - A RG To parse out the arguments passed to a program or internalsubroutine and store the arguments in variables
Ex :
/*REXX*/
arg a,b
c = a+ b
say µThe sum is µ c
exit
When invoked as TSO SUM 4 5,the output will be
The sum is 9
REXX does not prompt for any missing arguments
ARG converts the parameters passed to uppercase
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 42/147
REXX Instructions -
RE TU
R N
used to pass control back to the caller of a subroutine or
function.An optional value can also be passed
Syntax : RETURN {expression }
If invoked as a function ,the value in the return instruction
is substituted for the function call
If invoked as a subroutine , the value in the RETURN
instruction is stored in the REXX special variable RESULT
If the RETURN instruction doesn¶t have any expression ,
then a null string is passed to the caller
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 43/147
REXX Instructions -
C ALL
used to invoke an internal or external subroutine and built-
in-functions
The called routine usually uses the ARG function to extract
the parameters passed by the call
Examplearg x /* parse 'x' */call factorial x /* go get factorial of 'x' */say x'! =' result /* write result out */
exit
factorial: procedure /* factorial subroutine */arg n /* parse 'x' */if n=0 then return 1 /* quit when done */call factorial n-1 /* call myself with x minus 1 */
return result * n /* build up answer in 'result' */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 44/147
REXX Instructions - SI
G NAL
It is an equivalent command for the infamous GOTO
command in other languages
Syntax : SIGNAL label
Example/*REXX*/say µBefore signal¶ /* displayed */signal byesay µAfter signal¶ /* never gets executed */
exit bye:say µIn signal¶ /* displayed */exit
Note that the say instruction after signal will never get
executed
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 45/147
REXX Instruction - PUSH
used to place a new element on a REXX data stack
Syntax : PUSH {expression}
Places the element on the top of the REXX data stack
The length of an element can be up to 16,777,215
A null string of length zero is stacked if the expression is
omitted
stacks strings LIFO sequence
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 46/147
REXX Instruction - QU
E U E
used to place a new element on the bottom of a REXX data
stack
Syntax : QUEUE { expression }
stacks strings in FIFO sequence
a null length string is stacked if expression is omitted
The PULL instruction is used extract an element from the
top of the REXX data stack
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 47/147
REXX Functions
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 48/147
REXX FunctionsA function is a sequence of instructions that can receive data,
process that data, and return a value. In REXX, there are
several kinds of functions:
Built-in functions -- These functions are built into thelanguage processor. More about built-in functions appears
later in this topic.
User-written functions -- These functions are written by an
individual user or supplied by an installation and can be
internal or external.An internal function is part of the current
exec that starts at a label. An external function is a self-
contained program or exec outside of the calling exec
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 49/147
REXX Functions - ABS
Returns the absolute value of a number
The absolute value of a number is the value of the number
without the sign being considered
The number of digits returned is governed by current
NUMERIC DIGITS setting
Examples:
ABS(¶56.7') returns the number 56.7
numeric digits 2
ABS(' -0.125') returns the number 0.13
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 50/147
REXX Functions - ADD
RE SS
returns the current setting of the destination to which the
non-REXX commands in an REXX exec is addressed to
Note the the default destination is TSO
Example
/*REXX*/
say address() /* returns TSO */
address ispexec
say address() /* returns ISPEXEC */
address isredit /* returns ISREDIT */
say address()
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 51/147
REXX Functions -
CE NT
ER
used to center one string within a certain length area and
pad on the left and right of the centered string with an
optional padding character
Syntax : CENTER(string, length{,pad})
The default padding character is spaces
Examples :
say center(µuswest¶,10,¶*¶)
returns **USWEST**
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 52/147
REXX Functions -
C OMPA
RE
used to compare two strings and return a zero if the stringsare the same ,or a non-zero number if they are not
non-zero number is the position of the first mismatchingcharacter found
Syntax : COMPARE(string1,string2{,pad})
If the optional padding character is specified,then theshorter string is padded and compared
Examples :COMPARE('123','123') returns a 0 (exact match)
COMPARE('FO?? ','FO','?') returns a 5 (1st mismatch after padding)
COMPARE('abc','ak') returns a 2 (first mismatching char)
COMPARE('ZZ ','ZZ','x') returns a 3 (1st mismatch found 3 chars in)
COMPARE('MA ','MA') returns a 0 (exact match with padding)
COMPARE('xy ','xy',' ') returns a 0 (exact match with padding)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 53/147
REXX Functions -
C OPI
E S
used to concatenate or append a string to itself a certain
number of times
Syntax : COPIES(string,n)
Examples
COPIES('Hello',4) returns 'HelloHelloHelloHello'
COPIES('Say what?',0) returns '' (null string)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 54/147
REXX Functions - DATATYP
E
used to determine the data type of the string passed
Syntax : DATATYPE(string{,type})
If type is omitted,NUM is returned if the string is a validnumber and CHAR is returned in all other cases
If type is specified,either TRUE(1) or FALSE(0) is returned The valid types are as followsA - Alphanumeric N - NumericW - Whole number L - Lowercase
U - UppercaseM - Mixed case
ExamplesDATATYPE(' 44 ') returns NUM (numeric)DATATYPE('*1**') returns CHAR (caharcter string)DATATYPE('Wally','M') returns a 1 (mixed case)
DATATYPE('75.54','W') returns a 0 (not a whole number)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 55/147
REXX Functions - DAT
E returns the current date
An optional character can be passed to obtain date inspecific formats
Syntax : DATE({option})
Some of the chars that can be passed are
U returns date in USA format, 'mm/dd/yy¶
J returns a Julian date in the form 'yyddd¶
W returns the day of the week (e.g. 'Tuesday', 'Sunday', etc.)
Examplessay date() /* returns 17 Dec 1999 */
say date('U') /* returns 12/17/99 */
say date('J') /* returns 99351 */
say date('W') /* returns Friday */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 56/147
REXX Functions - D
E LST
R used to delete or remove one string from within another string
Syntax : DELSTR(string,n{,length})
'string' is the string from which a portion is to be deletedstarting with character number 'n', where 'n' is a positiveinteger
The length of the portion to be deleted is given by theoptional length parameter
When µn¶ is greater than the length of the string no action is performed
ExamplesDELSTR('abcde',3,2) deletes 'cd', leaving 'abe'
DELSTR('zyxw',3) leaves 'zy', deleting 'xw'
DELSTR('12345',6) no change, since 6 is greater than string length
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 57/147
REXX Functions - DI
G ITS
returns the current setting of the NUMERIC DIGITS
option
Takes no parameters
ExampleDIGITS() /* returns a 9 if REXX default hasn't been changed */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 58/147
REXX Functions - FO
R M
used to extract the current setting of the NUMERIC FORM
option
returns SCIENTIFIC or ENGINEERING
Example
say from() /* returns default scientific */
numeric form engineering
say form() /* returns engineering */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 59/147
REXX Functions - FO
R MAT
used to round off and format a number using REXX rules
optional values can be passed which decides the number of
digits before and after the decimal point
Syntax : FORMAT(number{,{before}}{,{after}})
If before and after are not specified ,the number of digits
that are needed to present the rounded number are used
ExamplesFORMAT('78',3) returns rounded number ' 78'
FORMAT(' - 8.7',,2) returns rounded number '-8.70'
FORMAT('5.46',3,0) returns rounded number ' 5'
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 60/147
REXX Functions - FUZZ
used to extract the current setting of the NUMERIC FUZZ
option
The value of FUZZ cannot be greater than the DIGITSsetting
Example
/*REXX*/
say fuzz() /* returns the default zero */
numeric fuzz 2
say fuzz() /* returns 2 */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 61/147
REXX Functions - IND
EX
used to find the position of one character string within
another character string
Syntax : INDEX(string,substring{,start})
'start' is an optional starting character position for the
search within µstring¶
ExamplesINDEX('hello','ll') returns a 3
INDEX('say what','w ') returns a 0
INDEX('zyxwvu','vu',6) returns a 0
INDEX('zyxwvu','vu',2) returns a 5
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 62/147
REXX Functions - L
E FT
used to extract the leftmost characters of the string
Syntax : LENGTH(string,length{,pad})
If string is shorter than length,the string returned is
padded with µpad¶ char in the function call if available or
with the default pad character blank.
Examples :
LEFT('Wallawalla',4) returns 'Wall'
LEFT('Republicans',20,'-') returns 'Republicans---------'
LEFT('Motley Crue ',8) returns 'Motley C'
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 63/147
REXX Functions - L
E N G
TH
used to return the length of the string passed to the
function
Syntax : LENGTH(string)
Examples :
LENGTH('LIFO') returns 4
LENGTH('Rubber baby buggy bumpers') returns 25
LENGTH('') returns 0 (null string)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 64/147
REXX Functions - MA
X
returns the maximum numeric value from a list of
numeric values
Syntax : MAX(number{,number}...)
The size of the numeric value returned is limited to thecurrent setting of NUMERIC DIGITS.
Up to 20 numbers may be specified as arguments to
MAX.
Calls to MAX can be nested if more are needed
Examples :
MAX(21,22,81,67) returns 81
MAX(27.32,0.45,102.3) returns 102.3
The MIN function is similar to MAX except that it returns the
minimum value
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 65/147
REXX Functions - POS
returns the position, relative to 1, of one string within
another.
Syntax : POS(substring,string{,startloc})
A zero is returned if substring is not found within µstring¶
Examples
POS('M','ABCDEFGHIJKLMNOPQRSTUVWXYZ') returns 13
POS('Smith','Merrill, Lynch, Pierce, Fenner, and Smith') returns 37
POS('hart','MVS is breaking my heart...',4) returns 0 (not found)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 66/147
REXX Functions - QU
E U E D
returns the no of elements that remain on the REXX datastack
No arguments
If queued() returns zero,that indicates the REXX data stack is empty and the next PULL instruction will obtain input fromthe TSO terminal
Example
/*REXX*/
newstack push a
queue b
say queued() /* returns 2 */
delstack
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 67/147
REXX Functions -
R ANDOM generates a "pseudo-random" number that will lie
somewhere between a supplied (or defaulted) upper andlower bound."pseudo-random" means that the number is nottruly random, but it behaves as if it was. Syntax : RANDOM({min}{,{max}{,seed}}) Difference between min & max <= 100000 the default value for min is 0 and max is 999 If only one number is supplied,then a number will begenerated in the range of zero to that number µseed¶ is an optional whole number and when specified
gives repeatable results each time the exec is invoked Examples :RANDOM() returns a random number 'n', in range 0 =< n =< 999
RANDOM(32,35) returns a random number 'n', in range 32 =< n =< 35
RANDOM(,,251) returns a random number 'n', in range 0 =< n =< 999,
and returns the same one every time called this way
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 68/147
REXX Functions -
RE V ER
S E
This function reverses the order of all characters in a string Syntax : REVERSE( string)
Example
say reverse(µTCSUSWEST¶)
returns µTSEWSUSCT¶
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 69/147
REXX Functions - SI
G N
used to determine the sign of a number
Syntax : SIGN(number)
returns -1 if the number is negative returns 0, if the nuber is zero
returns +1,if the number is positive
the number is rounded to meet the current setting for
NUMERIC DIGITS before the test.
Examples :SIGN('-22.811') returns -1
SIGN(0.0) returns 0
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 70/147
REXX Functions - ST
R IP
used to remove the leading and/or trailing characters from
a character string
Syntax : STRIP(string{,{option}{,char}})
The default char for µchar¶ is blank
The µoption¶ can take either L or T or B and the default
option is B
Examples :
STRIP(' February 11, 1989 ') returns 'February 11, 1989'
STRIP('7642.7600',T,0) returns '7642.76'
STRIP('$$$$52.4',Leading,$) returns '52.4'
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 71/147
REXX Function - SUBST
R
used to extract a portion of a string
Syntax : SUBSTR(string,n{,{length}{,pad}})
µlength¶ is the length of extracted substring
if µlength¶ is omitted,the remainder of the string from char
number µn¶ is extracted
The extract string is padded on the right with µpad¶ char, if
there are not enough characters in the extracted substring to
reach µlength¶
Examples :SUBSTR('Hi there',4) returns 'there'
SUBSTR('MVS',1,5) returns 'MVS '
SUBSTR('December 7, 1941',6,15,'-') + 'ber 7, 1941----'
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 72/147
REXX Function - SYMBOL used to determine whether a symbol is valid REXX symbol
Syntax : SYMBOL(name)
Returns ³BAD´ if the µname¶ is not a valid REXX symbol
If µname¶ is name of the variable with a value assigned to
it,¶VAR¶ is returned
In other cases, µLIT¶ is returned
Examples : j='TSO/E Version 2.1' /* assign value to variable J */
Symbol('J') /* returns VAR since assigned */
Drop j
Symbol('J') /* returns LIT after Drop */
Symbol('.variable') /* returns BAD since 1st character is a '.' */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 73/147
REXX Function - TIM
E
returns the current time of day in a variety of different
formats and can also be used to perform elapsed time
calculations
Syntax : TIME({option})µR¶ - elapsed time clock to be set to zero
µE¶ - return elapsed time since previous TIME(µR¶)
µH¶ - No. of hours since midnight
µL¶ - hh:mm:ss:uuuuuu
µS¶ - No. of seconds since midnight
Examples :TIME() returns 09:18:04TIME('L') returns 11:00:32.672567TIME('M') returns 840 /* at 2 in the afternoon */TIME('H') returns 12 /* at noon */TIME('R') returns 0 /* The first call */
TIME('E') returns 18.278190 /* about 18 seconds later */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 74/147
REXX Function - T
RUN
C
used to truncate a number to an integer portion and a
decimal fraction portion
Syntax : TRUNC(number{,n})
'n' is the number of decimal places to retain to the right of
the decimal point.If µn¶ is omitted,no decimal places are
returned
Examples:
TRUNC(4096.6904) /* returns 4096, dropping decimal fraction */
TRUNC(0.3,3) /* returns 0.300 */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 75/147
REXX Function - US
ER ID
returns the current TSO user id
Format : USERID()
Example
say userid() /* returns the current user id */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 76/147
REXX Function - WO
R D
used to extract a specific word from within a string of
words
Syntax : WORD(string,n)
The words in the string must be separated by blanks
µn¶ indicates that the nth word in the string is to be
extracted
Examples :WORD(¶Arise Awake and Stop not',4) /* returns ¶Stop' */
test = '1 2 3 4 5 6 7 8 9'
WORD(test,1) /* returns '1' */
WORD('Carolina moon, what are you doing over Gismo Beach?',10)
/* returns null string */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 77/147
REXX Function - WO
R DS
used to determine the number of words contained within a
string of words
Syntax : WORDS(string)
Examples :
WORDS(µArise, Awake and Stop not till the goal is reached¶)
/* returns 10 */WORDS('1234567890abcdefghikjlmnopqrstuvwxyz $@#!')
/* returns 2 */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 78/147
REXX TSO/ E External Functions
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 79/147
REXX TSO/
E e x
ternal functions
In addition to the built-in functions,TSO/E
provides external functions that you can use to do some
specific tasks.
Functions we will be discussing and frequently used are :
LISTDSI
OUTTRAP
SYSDSN
SYSVAR
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 80/147
LISTDSI -Ex
ternal Function Returns in variables the dataset attributes of a specified
dataset
The function call is replaced by a function code that
indicates whether or not the call was successful.A non-zerocode indicates that the call was not successful
Example
/*REXX*/
X=LISTDSI(³¶TCS.PDS.COBOL¶´) /* x = function code */IF X=0 THEN DO
SAY µSYSDSORG µ SYSDSORG
SAY µSYSLRECL µ SYSLRECL
END ELSE SAY µCALL UNSUCCESSFUL¶
EXIT
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 81/147
LISTDSI -Ex
ternal functionThe following points are note-worthy
Note two sets of quotes in the call to LISTDSI
³ - to indicate the parm is literal to REXXµ - to indicate the dsname is fully qualified
The function code should always be checked after the call
The output of the above REXX could be
SYSDSORG PO - PO- Partitioned Dataset
SYSLRECL 80 - Record length
Totally there are 33 variables that are set as a result of the
call to LISTDSI external function
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 82/147
OUTT R
AP -Ex
ternal Function Traps TSO/E command output into a stem variable
The function call returns the name of the variable
specified
Trapping is capturing the lines of data which otherwise
would have been displayed at the terminal
Example
/*REXX*/x=outtrap("a.") /* turns trap on. x=a. */
"listds 'rhkrish.rexx.exec' members"
x=outtrap("off") /* turns trap off. x=off */
say 'No of lines trapped ' a.0
EXIT
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 83/147
OUTT R
AP -Ex
ternal functionContd..
The output of the exec could be this
No of lines trapped 57 Note that the no of lines trapped is stored in A.0
All the trapped lines from A.1 to A.n can be used
The outtrap function can be used to trap only a certain no
of lines.
OUTTRAP(³A.´,10)
Only 10 lines trapped.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 84/147
SYSDSN -Ex
ternal Function Returns OK if the specified dataset exists; Otherwise
returns appropriate error messages
Example call
available = SYSDSN(³¶tcs.rexx.exec¶´)/* available could be set to "OK" */
The other possible error messages are as followsMEMBER SPECIFIED, BUT DATASET IS NOT PARTITIONED
MEMBER NOT FOUND
DATASET NOT FOUNDERROR PROCESSING REQUESTED DATASET
PROTECTED DATASET
VOLUME NOT ON SYSTEM
UNAVAILABLE DATASET
INVALID DATASET NAME, data-set-name
MISSING DATASET NAME
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 85/147
SYSVA R
-Ex
ternal Function Uses specific argument values to return information about
the user ,terminal ,language ,system ,exec and console
session
Example
say sysvar(sysuid)
displays the user id.
The arguments corresponding to user information are
SYSPREF - Prefix as defined in user profile
SYSPROC - Logon procedure of current session
SYSUID - User id of current session
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 86/147
SYSVA R
-Ex
ternal Function Terminal information
SYSLTERM - No of lines available on screen
SYSWTERM - Width of screen
Exec informationSYSENV - Whether exec is running in fore or background
SYSISPF - whether ISPF is active or not
System information
SYSRACF - Whether RACF is availableSYSNODE - Network node name
SYSTSOE - Level to TSO/E installed
Note : Only some of the variables are covered
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 87/147
REXX TSO/ E C ommands
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 88/147
REXX
TSO/ E
C
ommands Commands provided with the TSO/E implementation
of the language. These commands do REXX-related tasks
in an exec, such as:
- Control I/O processing of information to and from data
sets(EXECIO)
- Perform data stack services (MAKEBUF, DROPBUF,
QBUF, QELEM,NEWSTACK, DELSTACK, QSTACK)
- Change characteristics that control the execution of anexec
- Check for the existence of a host command environment
(SUBCOM).
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 89/147
REXX
C
ommand - N E
WSTACK
used to create a new data stack in the REXX environment
When this command is executed, the current data stack issaved and a new stack is created and made the current stack
When the stack is empty,the subsequent pull instruction
obtains input from the TSO terminal When the stack has data elements,the pull instruction getsthe input from the top of the stack
Example"NEWSTACK" /* creates new stack */
Push tcs /* puts µtcs¶ in top of stack */Push uswest /* puts µuswest¶ over µtcs¶ */ pull data /* pulls data from the top of stack */say µfrom the stack µ data /* displays µuswest¶ */ pull data /* pulls data from top of stack */say µfrom the stack µ data /* displays µtcs¶ */ pull data /* obtains input from tso terminal */
"DELSTACK" /* delete stack */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 90/147
REXX
C
ommand - D E
LSTACK
used to delete the data stack that was created last in theREXX environment
When this command is executed the most recently createdstack is deleted and all elements on it are purged
If there is any previous data stack,that is made available
Example :³NEWSTACK´ /* new stack is created */
push a /* µa¶ is stored on top */
queue b /* µb¶ is stored at the bottom */
³NEWSTACK´ /* new stack is created */ push c /* µc¶ is stored on top */
say queued() /* displays 1 */
³DELSTACK´ /* deletes the current stack */
say queued() /* displays 2 */
³DELSTACK´ /* deletes the stack */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 91/147
REXX
C
ommand - MA KE
BUF used to add a buffer to the data stack in REXX environment
returns the relative number of the buffer on the stack in the
special variable RC
It¶s a temporary extension to the data stack and used whenneed arises to pass some of the elements to a subroutine
Example :³NEWSTACK´ /* creates new stack */Push elem1 /* add an element */
"MAKEBUF" /* add a buffer to stack */saverc = RC /* save number of buffer */
Push elem1 /* add contents of variable elem1 to data stack */
Push saverc /* pass buffer number too */
Call subrtn1 /* call subroutine to handle elements */
"DROPBUF" /* delete buffer,but not stack before makebuf */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 92/147
REXX C ommand - D ROPBUF used to delete data stack buffer from the data stack in the
REXX environment
Syntax : DROPBUF {n}
'n' is optional and is the number of the data stack buffer that you wish to remove. That data stack buffer and all those
higher on the stack are removed from the stack when
DROPBUF is executed
If n is omitted ,the recently created buffer is dropped Example :
³DROPBUF ´ /* deletes the recently created buffer */
³DROPBUF 0´ /* deletes buffer and all elements of stack */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 93/147
REXX C ommand - QBUF used to determine the number of data stack buffers that have
been explicitly created by the MAKEBUF REXX command
number of buffers will be returned through special variable
RC
If no buffers have been created via makebuf , a 0(zero) is
returned is RC
Example :
"MAKEBUF" /* creates buffer 1 */
"MAKEBUF" /* creates buffer 2 */
"DROPBUF" /* deletes buffer 2 */
"MAKEBUF" /* creates buffer 2 again */
"QBUF" /* returns a 2 */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 94/147
REXX C ommand - Q E L E M The QELEM REXX command is used to determine the
number of data stack elements that are contained in the
buffer that was most recently created by the MAKEBUF
REXX command
If no buffers have been created via makebuf , a 0 is
returned in RC
Example :"MAKEBUF" /* creates a buffer */
Push µTCS¶Push µTATA¶Push µCONSULTANCY¶Push µSERVICES¶"QELEM" /* returns a 4 in RC */"DROPBUF" /* deletes buffer and elements in it */"QELEM" /* returns a 0 in RC */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 95/147
REXX C ommand - QSTACK used to determine the total number of data stacks currently
is existence
The no of data stacks includes the original REXX data
stack, as well as those created via the NEWSTACK command
If no additional stacks have been created via NEWSTACK
, a 1 is returned is RC
Example
"QSTACK" /* returns a 1 in RC */
"NEWSTACK" /* creates a new data stack*/
"NEWSTACK" /* creates another new data stack*/
"QSTACK" /* returns a 3 in RC */
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 96/147
REXX C ommand - EXEC IO used to perform read and write operations against a
sequential dataset or a pds member
The data is either read from the data set and placed on the
data stack or into a list of variables, or written from the datastack or a list of variables into the data set
Syntax for read operations :
EXECIO {lines ¦ *} DISKR ddname {linenum}
{ ( {{FINIS}} ¦ { STEM var {FINIS} } {)} }
Syntax for write operations :
EXECIO {lines ¦ *} DISKW ddname { ( {STEM var} {FINIS} {)} }
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 97/147
REXX C ommand - EXEC IO Example
/* read all lines in data set and display them */Address TSO /* pass unknowns to TSO */
Parse Arg dsn /* get data set name */"ALLOC DD(TEMP) DA("dsn") SHR" /* allocate file */
end_of_data = 0 /* negate end of file */
Do While end_of_data = 0
'EXECIO 1 DISKR TEMP ( FINIS' /* read a record onto stack */
If RC = 2 then end_of_data = 1 Else Nop /* set end-of-file? */
Pull line /* get line off stack */Say line /* display line */
End
Note : This example uses the original REXX data stack.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 98/147
REXX C ommand - EXEC IO/* Example 2 - copy a file into another */
Address TSO
"ALLOC F(IN) DA('SYS1.PROCBLIB(ASMHCL)') SHR"
"ALLOC F(OUT) DA(µTATA001.DELETE.ME¶) SHR"
'EXECIO * DISKR IN (STEM DATA. FINIS' /* copy file into stem*/Queue /* add null line to stack */
'EXECIO * DISKW OUT (STEM DATA. FINIS' /* copy using stem*/
"FREE F(IN,OUT)"
SAY µNo of lines in input : µ data.0
EXIT
Note : This example uses stem variable data to read the contents of input
file.The Number of lines read will be stored in data.0.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 99/147
Executing REXX in Batch
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 100/147
Executing REXX in batch
Need arises when the REXX exec takes longer time
to complete the execution.So time-consuming and low
priority execs can be run in background
Main advantage - Batch mode does not interfere with persons use of the terminal
Only those execs which do not require any sort of
terminal interaction can be run in batch mode.
A JCL as shown in the next slide can be used to
invoke a REXX exec.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 101/147
Executing REXX in Batch - J C L//TSOBATCH EXEC PGM=IKJEFT01,DYNAMBR=30,REGION=4096K
//SYSEXEC DD DSN=TCS.REXX.EXEC,DISP=SHR
//SYSTSPRT DD SYSOUT=A
//SYSTSIN DD *
% SETUP
/*
//
The following points are to be noted :
IKJEFT01 - TSO command processor program
SYSEXEC - System DD card to which REXX librariesare concatenated
SYSTSPRT - Destination of the REXX output,as wellthe TSO command processor
Contd.«.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 102/147
Executing REXX in Batch - J C LContd.«.
SYSTSIN - Instream card wherein TSO commands or invocation of REXX execs can be issued
The dataset TCS.REXX.EXEC is a PDS and has amember of the name SETUP.
The Instream data can be used to invoke an REXX execeither implicitly or explicitly as indicated below
%SETUP >>>> Implicit
EXEC µTCS.REXX.EXEC(SETUP)¶ EXEC >>>> Explicit
Any parameters to the exec can be passed as below
%SETUP µparm1¶ µparm2¶
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 103/147
REXX Exec - ExampleAfter the execution of the exec,If there are any elements in
the REXX data stack,those elements will be treated as TSO
commands and will get executed
Example - To purge a user Id
/*REXX*/
arg uname
queue ³c u =³uname
queue ³end´
³OPER´
exit
Invoke the above exec as ===> TSO CUSER TATA001
A similar exec can be written to display all the users
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 104/147
REXX E DIT MACRO
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 105/147
E dit Macros - Introduction Primary commands that users write.An example is the oft-used CUT R or the PASTE K command
Using Edit macros save time and keystrokes
- Deleting all the lines with first character as µ*¶ Edit macro is a series of edit commands placed in a datasetor a member of partitioned dataset
- To find lines with char µa¶ in Col. 31 and char µb¶ inCol. 35
Used to perform often-repeated tasks
- Block commenting lines in a COBOL program
To run an Edit macro,Type its name and any operands on
the command line and press enter
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 106/147
E dit Macros - BasicsAssignment statement
Consists of two parts ,values and key-phrases,which areseparated by an equal sign
Value segment is the data in the macro and key-phrase
segment represents the data in the editor Can be used to pass data from the edit macro to the editor or to transfer data from the editor to the edit macro
Data is always transferred from the right hand side of theequal sign in an assignment statement to the left hand side
Example : ³ISREDIT (data) = LINE .ZCSR´
The data in the current line is stored in the variabledata.so the value segment is data,key-phrase segment is LINEand hence the transfer of data is from the editor to the editmacro.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 107/147
E DIT Macros - Parameters
Parameters can be passed to the EDIT macro using the
statement µISREDIT MACRO(parm)¶
Suppose the macro name copymem and If it is invoked as
Command ====> COPYMEM MYFIRST
then MYFIRST is assigned to the variable µparm¶.
More than one variable can be passed
If there are more variable names than parameters, theunused variables are set to nulls.
The macro statement should be the first executable
statement in a macro
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 108/147
E DIT Macros - LabelsA Label is an alphabetic string character used to name lines
A label must begin with a period (.) and be followed by no
more than 8 alphabetic characters, the first of which cannot
be Z. No special characters or numeric characters are
allowed.
The editor-assigned labels are:
.ZCSR The data line on which the cursor is currently
positioned
.ZFIRST The first data line Can be abbreviated .ZF
.ZLAST The last data line. Can be abbreviated .ZL
.ZFRANGE The first line in a range specified by you.
.ZLRANGE The last line in a range specified by you.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 109/147
E DIT Macro - Assignment stmts. MEMBER
Retrieves the name of the library member being edited
If a sequential dataset is being edited ,the variable is set to blanks
µISREDIT (memname) = MEMBER¶
DATASET
Used to get the current dataset name
µISREDIT (dsnname) = DATASET¶
LOCATE
Used to position the cursor in a particular line using label or the line number
µISREDIT LOCATE .ZCSR¶
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 110/147
E DIT MACRO - Ex : Showonly
/*REXX*/
"ISREDIT MACRO (STRING)" /* STRING IS THE PARAMETER */
"ISREDIT X ALL" /* EXCLUDE ALL LINES */
"ISREDIT F ALL " STRING /* FIND ONLY PARM PASSED */
EXIT
This macro is very simple one and uses EXCLUDE and
FIND macro commands
It displays only the lines with the string passed to the macro
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 111/147
E DIT Macro - Assignment stmts. CURSOR
used to position the cursor in a particular row and column
µISREDIT (row,col) = CURSOR¶
µISREDIT CURSOR = (row,col)¶ LABEL
sets or retrieves the values for the label on the specified lineand places the values in variablesµISREDIT (var1) = LABEL .ZCSR¶
µISREDIT LABEL .ZCSR = (.here)¶
LINENUM
retrieves the current relative line number of a specified label
µISREDIT (lnum) = LINENUM .ZL¶
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 112/147
E DIT Macro - Assignment stmts. LINE
Sets or retrieves the data from the data line specified by theline pointer
µISREDIT (lndata) = LINE .ZCSR¶
µISREDIT LINE .ZCSR = (datavar)¶ LINE_AFTER
Adds a line after a specified line in the current datasetISREDIT LINE_AFTER lptr = <DATALINE> data
<INFOLINE>
<MSGLINE ><NOTELINE>
µISREDIT LINE_AFTER .ZCSR = DATALINE (datavar)¶
LINE_BEFORE
Similar to the LINE_AFTER stmt except that it adds a line
before the specified the line
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 113/147
E DIT Macro - Assignment stmts. RANGE_CMD
Identifies the name of a line command entered from the
keyboard
µISREDIT (varname) = RANGE_CMD¶
NUMBER Sets number mode, which controls the numbering of lines in
the current data.
µISREDIT NUMBER ON STD COBOL¶
µISREDIT NUMBER ON STD DISPLAY¶
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 114/147
E DIT Macro - Ex : VSAV E /*REXX*/
/* This macro is used to save a member of a PDS when in view mode */
'isredit macro' /* No arguments */
address isredit /* Changing the host environment */
"(mem) = MEMBER" /* storing member name in mem */
"(dsn) = DATASET" /* storing dsname is dsn */If mem = '' then do /* if mem is spaces,its PS */
say 'designed for PDS member'
exit /* exit from program */
end
"isredit save" /* trying to save the source */
if rc = 0 then do /* Not in view mode */
say 'Not in view mode.use SAVE'
exit /* Exit from the program */
end
Contd.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 115/147
E DIT Macro - Ex : VSAV E "isredit repl .zf .zl " mem /* Issuing replace command */
if rc = 0 then /* check for success */
say 'member saved.Exit from view mode'
else
say 'member not saved.Return code ' RC
exit
The macro can be used to save a member of a PDS,when it is
opened in view mode.
It checks whether the dataset being edited is a PDS
It also checks whether the EDIT is in VIEW mode by tryingto save the dataset
After these checks,the REPL command is issued.
Note : CREATE command can be used to create a new
member with the same data
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 116/147
E DIT Macro C ommand PROCESS
allows the macro to control when line commands or data
changes typed at the keyboard are processed
ISREDIT PROCESS <DEST> <RANGE cmd1 <cmd2>> µDEST¶ specifies that the macro can capture an A or B line
command .The .ZDEST label is set to the line preceding the
insertion point.If A or B is not not entered ZDEST is set to
last line
RANGE specified the line commands µcmd1¶ and µcmd2¶which the user can enter
The .ZFRANGE label is set to the first line identified by
the line command that you have entered, and .ZLRANGE is
set to the last line.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 117/147
E DIT Macro - Ex : C OMM E NT /*REXX*//*used to comment eztrieve source code in edit/view mode */address isredit /* Changes environment */'MACRO NOPROCESS' /* all line cmds -process later */'PROCESS RANGE N' /* process line cmd N now */if rc ¬= 0 then do /* error if no ln cmd N entered */say 'enter the n line command'exit
end'(lcmd) = RANGE_CMD' /* stores the lncmd entered */'(first) = LINENUM .zfrange' /* stores the first range of N */'(last) = LINENUM .zlrange' /* stores the last range of N */
if first ¬= last then do /* adds note to mark begin& end */temp = '*** comment changes ends ***''LINE_AFTER 'last' = NOTELINE (temp)'temp = '*** comment changes begins ***''LINE_BEFORE 'first' = NOTELINE (temp)'
end
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 118/147
E DIT Macro - Ex : C OMM E NT Do I = first to last /* first range to last range */
'SHIFT ) ' I /* shifts chrs to right 2 cols */
'LINE ¶I' = LINE + *' /* overlays first char with '*' */
End
Exit
the line command µN¶ must be entered prior to invoking the
macro
Line command - N , NN-NN , Nn
Note the use of NOTELINE SHIFT command shifts chars to right
To remove the comments,use the built-in µ((µ left shift line
command
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 119/147
E DIT Macros - Ex : C PB K /*REXX*/
/* used to zoom a copybook in a cobol program */
/* TEST COPY USWNOTE1. */
ADDRESS ISREDIT
'MACRO'
'(lnum) = LINENUM' .ZCSR '(lndata) = LINE' lnum
lndata = strip(lndata)
dspos = pos('COPY',lndata)
if dspos = 0 then SIGNAL error_msg
lastpos = pos('.',substr(lndata,dspos+5))
member = substr(lndata,dspos+5,lastpos-1)member = strip(member)
dsname = 'app1.common.prod.copylib('||member||')'
address ispexec
"browse dataset('"dsname"')" ;
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 120/147
E DIT Macros - Ex : C PB K error_msg:
say 'Place the cursor over the COPY verb'
exit
used to browse a copybook mentioned in a COPY verb of a
COBOL program Note the use of SIGNAL instruction
The macro command can be typed at the command prompt
and cursor can be moved to the COPY verb
This macro can also be assigned to a function key using
KEYS command and may be invoked by pressing the
particular key when the cursor is over the COPY verb
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 121/147
FIL E TAILO R IN G
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 122/147
FT - Skeletons Skeletons are members of a PDS that have variables and
fixed text.They may be part of a JCL.(Ex JOB stmt)
The skeleton files can contain variable-length records,
with a maximum record length of 255.
Skeletons can be included in a dataset to build a
complete JCL during the run time
Skeleton libraries are to be allocated to the application
library ddname ISPSLIB
The allocation should be done before invoking ISPFAllocation can be done temporarily using ISPF service
LIBDEF
LIBDEF ISPSLIB DATASET ID(µTATA.PDS.SKELS¶)
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 123/147
File Tailoring - FTOP E N Allows skeleton files to be accessed from the skeleton libraryspecified by ddname ISPSLIB
Output from the file tailoring process will be placed in atemporary file.The name of the temporary file will be stored in
the profile variable ZTEMPF If the output is to be saved in a PS or PDS , the particular library has to allocated to the ddname ISPFILE
Call invocation format
ISPEXEC FTOPEN [TEMP]
TEMP specifies whether the output is to be placed intemporary file or not
If TEMP is not specified,then the ddname ISPFILE should
have been allocated rior to the invocation of FTOPEN
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 124/147
File Tailoring - FTIN C L
Specifies the skeleton that is to be used to produce the file
tailoring output
Command invocation format
ISPEXEC FTINCL skel-name [NOFT]
NOFT specifies that no file tailoring is to be performed on
the skeleton.So the entire skeleton will be copied to the
output file exactly as is with no variable substitution or
interpretation of control records
NOFT can be used when there are no variables in the
skeleton to be included
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 125/147
File Tailoring - FT C LOS E used to terminate the file tailoring process and to indicate thefinal disposition of file tailoring output
Command invocation format
ISPEXEC FTCLOSE [NAME(member-name)]
[LIBRARY(library)][NOREPL]
NOREPL specifies that FTCLOSE is not to overlay anexisting member in the output library NAME specifies the name of the member in the outputlibrary that is to contain the file tailoring output LIBRARY specifies the name of a DD statement or lib-typeon the LIBDEF service request that defines the output libraryin which the member-name exists. If specified, a generic(non-ISPF) DD name must be used. If this parameter isomitted, the default is ISPFILE.
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 126/147
File Tailoring - Example
Assume skeleton library as TATA.UTIL.SKELS
Skeleton member JOBSTMT//&JOBNAME JOB (BILL01E0),¶TATA',NOTIFY=&&SYSUID,
// MSGCLASS=T,MSGLEVEL=(1,1) Skeleton member SYNCSORT//STEP01 EXEC PGM=SYNCSORT,REGION=400K
//SORTIN DD DISP=SHR,DSN=&OLDSRC
//SORTOUT DD DISP=SHR,DSN=&NEWSRC
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
/*
These are the two skeletons we will be using in the REXX
exec to build the sort cl
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 127/147
File Tailoring - Example
/*REXX*/"ispexec libdef ispslib dataset id(¶tata.util.skels')"say 'enter the jobname :' pull jobname
say 'enter old source dsn :' pull oldsrcsay 'enter new source dsn :' pull newsrc"ispexec ftopen temp""ispexec ftincl jobstmt ""ispexec ftincl syncsort ""ispexec ftclose ""ispexec vget (ztempf)""ispexec edit dataset('"ztempf"')"exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 128/147
File Tailoring - Example
If you respond to the prompts for jobname,old dsname andnew dsname with jobsort,tata.old.file and tata.new.filerespectively,the tailored output will look like
//JOBSORT JOB (BILL01E0),¶TATA',NOTIFY=&SYSUID,// MSGCLASS=T,MSGLEVEL=(1,1)//STEP01 EXEC PGM=SYNCSORT,REGION=400K //SORTIN DD DISP=SHR,DSN=TATA.OLD.FILE//SORTOUT DD DISP=SHR,DSN=TATA.NEW.FILE//SYSPRINT DD SYSOUT=*//SYSIN DD *
SORT FIELDS=(1,10,CH,A)/*
Note that all three variables have been substituted with
appropriate values
Note the single ampersand in the NOTIFY parameter
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 129/147
ISPF Panels
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 130/147
A Simple panel definition)ATTR DEFAULT(%+ _)
% TYPE(TEXT) INTENS(HIGH)+ TYPE(TEXT) INTENS(LOW) _ TYPE(INPUT) INTENS(HIGH) CAPS(ON) JUST(LEFT)
)BODY+ A Sample panel - REXX Training+ -------------------------------------
+ + %Enter your name please ==>_urname + + + %Name cannot exceed more than 15 chars + + + +Press ENTER to continue,PF3 to exit + +
+ + )INIT)PROC
VER (&URNAME,NB,ALPHAB))END
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 131/147
REXX Exec - Panel Ex./*REXX*/
"ispexec libdef ispplib dataset id('rhkrish.test.panels')"
"ispexec display panel(expan)"
if RC ¬= 0 then do
say 'command cancelled'
exitend
else
say 'Your name is ' urname
exit
A simple REXX Exec that displays a panel that prompts for
the user nameAfter the panel is submitted, the name entered is displayed
After the panel is displayed and inputs are entered,if enter is
pressed RC is zero and if PF3 pressed, RC will be 8
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 132/147
REXX - Panel Ex. Output
A Sample panel - REXX Training
-------------------------------------
Enter your name please ==> abcdefghijklmno
Name cannot exceed more than 15 chars
Press ENTER to continue,PF3 to exit
Advanced panels
Point and Shoot Fields
Action Bar Choice
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 133/147
ISPF TABL E S
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 134/147
ISPF Tables
ISPF tables are analogous to arrays
A table can exist with or without a keyAn ISPF table is stored in a PDS dataset
Application library - ISPTLIB
The table output library must be allocated to a ddname of
ISPTABL
There are over 20 ISPF services that are relevant to tables
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 135/147
ISPF Tables - TBCRE AT E creates a new table in virtual storage and opens it for
processing
allows specification of the variable names that correspond to
columns in the table
one or more variables can be defined as keys to a table
Command invocation formatISPEXEC TBCREATE table-name [KEYS(key-name-list)]
[NAMES(name-list)]
[WRITE|NOWRITE] table-name can be 1 to 8 alphanumeric characters in length
and must begin with an alphabet
name-list are the list of variables that forms the columns of
the table
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 136/147
ISPF Tables - TBCRE AT E
WRITE is the default option and indicates that the table is
permanent and is to be saved either by TBSAVE or TBCLOSE
NOWRITE specifies that the table is for temporary use onlyand it is to be deleted by either TBEND or TBCLOSE
Example
³TBCREATE FSTATUS KEYS(FCODE) NAMES(MESSAGE) WRITE ³
³TBCREATE TELBOOK KEYS(TELNO) NAMES(ADR1 ADR2)´
³TBCREATE ADDRESS NAMES(NAME ADDR1 ADDR2 PIN) ³
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 137/147
ISPF Tables - TBOP E N reads a permanent table from the table input file into
virtual storage, and opens it for processing
Command invocation format
ISPEXEC TBOPEN table-name [WRITE|NOWRITE]
Example
³ISPEXEC TBOPEN FSTATUS WRITE´ and
³ISPEXEC TBOPEN FSTATUS ´ are the same as WRITE isthe default option
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 138/147
ISPF Tables - TBADDAdds a new row of variables to the table
For tables without keys,the row is added after the current
row
For tables with keys ,the table is searched to ensure that thenew row has a unique key
Command invocation formatISPEXEC TBADD table-name
[SAVE(name-list)]
[ORDER]ORDER ensures no duplicate key condition
Example³ISPEXEC TBADD TELBOOK ORDER´
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 139/147
ISPF Tables - TBS C AN Searches a table for a row with values that match an
argument list
Command invocation format
³ISPEXEC TBSCAN table-name [ARGLIST(name-list)]´
Example
³ISPEXEC TBSCAN FSTATUS ARGLIST(FCODE)´
Searches the table FSTATUS using the argument FCODE and
fetches the error message associated with it.If the row exists inthe table, the error message will be stored in the variable
MESSAGE as in the TBCREATE service
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 140/147
ISPF Tables - TBS K IP
Moves the current row pointer of a table forward by +1
All variables in the row,including keys and extensionvariables ,If any ,are stored into the corresponding variables as
defined in the TBCREATE statement
Command invocation format
³ISPEXEC TBSKIP table-name´
TBSKIP has many other parameters which are beyond the
scope of this training
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 141/147
ISPF Tables - TBSAV E writes the specified table from virtual storage to the table
output library
The table output library must be allocated to the ddname
ISPTABL
The table must be open in WRITE mode
TBSAVE does not delete the virtual storage of the table
Command invocation format
ISPEXEC TBSAVE table-name NAME(alt-name)
µalt-name¶ - the table will stored in the output library with the alternate
name
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 142/147
ISPF Tables - TB E ND
deletes the virtual storage copy of the specified
table,making it unavailable for further processing
The permanent copy is not changed
Command invocation format
³ISPEXEC TBEND table-name´
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 143/147
ISPF Tables - TBC LOS E Terminates processing of a specified table and deletes the
virtual storage copy
If the table was opened in write mode ,TBCLOSE copies
the table from virtual storage to the table output library
If the table was opened in NOWRITE mode ,TBCLOSE
simply deletes the virtual storage copy
Command invocation format
ISPEXEC TBCLOSE table-name
Example
³ISPEXEC TBCLOSE FSTATUS´
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 144/147
ISPF Tables - Example - 1 Creating and storing data in a table
/*REXX*/
address ispexec
"libdef isptabl dataset id('rhkrish.test.tables')""tbcreate rexxerr keys(ecode) names(etext) write"
do i = 1 to 49
ecode=i
etext= errortext(i)
"tbadd rexxerr order"end
"tbclose rexxerr"
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 145/147
ISPF Tables - Example - 2 Searching the table for a particular value
/*REXX*/
address ispexec
"libdef isptabl dataset id('rhkrish.test.tables')"
"tbopen rexxerr nowrite"say 'enter the error code (1-49) :'
pull ecode
"tbscan rexxerr arglist(ecode)"
if rc = 0 then say 'The error mesg is ' etext
else say 'row does not exist'
"tbclose rexxerr"
say 'Error mesg using function-' errortext(ecode)
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 146/147
ISPF Tables - Example 3 Displaying all the rows of a table
/*REXX*/
address ispexec
"libdef isptabl dataset id('rhkrish.test.tables')"
"tbopen rexxerr nowrite"
"tbskip rexxerr"
if RC ¬= 0 then do
say 'tbskip error RC - ' RC
exit
end
say "ECODE ETEXT"
do while RC = 0say ecode etext
"tbskip rexxerr"
end
"tbclose rexxerr"
exit
8/9/2019 27129794 Rexx Training
http://slidepdf.com/reader/full/27129794-rexx-training 147/147
List of References REXX in the TSO Environment - Gabriel F.Gargiulo
Book manager in MVS
Shelf Name Description
TSO_V2R5 TSO/E V2R5 Bookshelf
ISPF_V42 ISPF 4.2 for MVS Library
Book Name Book Title
IKJ2C307 TSO/E V2R5 REXX/MVS User's Guide
ISPEEM01 Edit and Edit Macros