Restructured Exented Executor: Nagaraju Domala
Restructured Exented Executor: Nagaraju Domala
Restructured Exented Executor: Nagaraju Domala
zJournal http://www.mainframezone.com/z-journal
• Data Stack
• Stacking & Queuing Data
• Query Commands
• File Handling
• EXECIO
• Reading / Writing records
• Parsing techniques
• Lab Exercise
Nagaraju Domala
Data stack
Nagaraju Domala
Data stack
Nagaraju Domala
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
Nagaraju Domala
QUEUE
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
Nagaraju Domala
NEWSTACK
Used to create a new data stack in the REXX environment
When this command is executed, the current data stack is
saved 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 gets
the input from the top of the stack
Nagaraju Domala
DELSTACK
• Used to delete the data stack that was created last in the REXX
environment
• When this command is executed the most recently created
stack is deleted and all elements on it are purged
• If there is any previous data stack, that is made available
“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 */
Nagaraju Domala
QSTACK
Used to determine the total number of data stacks
currently in 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
"QSTACK" /* returns a 1 in RC */
"NEWSTACK" /* creates a new data stack*/
"NEWSTACK" /* creates another new data stack*/
"QSTACK" /* returns a 3 in RC */
Nagaraju Domala
FILE HANDLING IN REXX
Nagaraju Domala
EXECIO
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 data stack or a list of variables into the data set
Syntax for read operations :
Nagaraju Domala
DISKR
In all the above cases, the lines are read on to the STACK
“EXECIO * DISKR myindd (STEM newvar.” - reads into a
stem of variables called newvar
Nagaraju Domala
DISKW
Writes to dataset/member
/* rexx*/
Address TSO
dsn = "'UADA012.REXX.SOURCE(LOOP)'"
out = "'UADA012.REXX.SOURCE(LOOPX)'"
"ALLOC DD(TEMP1) DA("dsn") SHR REUSE"
"ALLOC DD(TEMP2) DA("out") SHR REUSE"
'EXECIO * DISKR temp1(STEM DATA. FINIS'
'EXECIO * DISKW temp2(STEM DATA. FINIS'
SAY DATA.0
'EXECIO * DISKR temp2(STEM DATA. FINIS'
SAY DATA.0
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.
Nagaraju Domala
EXECIO
/* Example - copy PDS member into another and to a new PS */
/* REXX */
Address TSO
IN = "'UADA012.REXX.SOURCE(LOOP)'"
out = "'UADA012.REXX.SOURCE(LOOPX)'"
out2= "'UADA012.REXX.DAY2'"
"ALLOC DATASET("OUT2") DDNAME(OUT2) NEW LRECL(133) ",
"BLKSIZE(1330) RECFM(F,B)"
"ALLOC DD(TEMP1) DA("IN") SHR REUSE"
"ALLOC DD(TEMP2) DA("OUT") SHR REUSE"
'EXECIO * DISKR temp1(STEM DATA. FINIS'
'EXECIO * DISKW temp2(STEM DATA. FINIS'
'EXECIO * DISKW OUT2(STEM DATA. FINIS'
SAY DATA.0
'EXECIO * DISKR temp2(STEM DATA. FINIS'
SAY DATA.0
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.
Nagaraju Domala
Parsing Techniques
Nagaraju Domala
Parsing
Nagaraju Domala
Parsing
Blank - an example
Each variable name gets one word of data in sequence
except for the last, which gets the remainder of the
data
v1 contains ‘Value’
v2 contains ‘ with Blanks.’
Nagaraju Domala
Parsing
Nagaraju Domala
Parsing
PARSE VAR InVar Out1Var Out2Var Out3Var
where:
Nagaraju Domala
Parsing
Substitution - an example
v1 contains ‘Value’
v2 contains ‘Periods’
Nagaraju Domala
Parsing
PARSE VAR InVar Out1Var . Out2Var
where:
Nagaraju Domala
Parsing
Separators - an example
phrase = ‘Dun , Bradstreet’
Nagaraju Domala
Parsing
PARSE VAR InVar Out1Var "," Out2Var
where:
Nagaraju Domala
Parsing
PARSE VAR InVar Out1Var (In2Var) Out2Var
where:
Nagaraju Domala
Parsing
Nagaraju Domala
Parsing
Absolute column position - another example
quote = ‘Dun & Bradstreet’
Nagaraju Domala
Parsing
Relative column position - an example
quote = ‘Dun & Bradstreet’
Nagaraju Domala
Parsing
A = '123456789abcdefghij'
Nagaraju Domala
Quiz
/* v1 receives "The" */
/* v2 receives "merry" */
/* v3 receives "wives" */
/* v4 receives "of" */
/* v5 receives "Windsor" */
Nagaraju Domala
Quiz
line1 = 'The merry wives of Windsor'
Nagaraju Domala
Parsing
/* v1 receives "The" */
/* v2 receives "merry" */
/* v3 receives "wives" */
/* v4 receives "of" */
/* v4 receives "of Windsor" */
Nagaraju Domala
Quiz
line1 = 'The merry wives of Windsor'
Nagaraju Domala
Quiz
/* v1 receives "The" */
/* v2 receives "merry" */
/* v3 receives "wives" */
/* v4 receives "of" */
/* "Windsor" is discarded */
Nagaraju Domala
Quiz
line1 = 'The merry wives of Windsor'
Nagaraju Domala
Quiz
/* "The" is discarded */
/* v2 receives "merry" */
/* "wives" is discarded */
/* v4 receives "of" */
/* "Windsor" is discarded */
Nagaraju Domala
Quiz
line1 = 'abcdefghijklmnopqrstuvwxyz'
Parse Var line1 1 v1 4 . 20 v2 22 . 26 v3
Nagaraju Domala
Quiz
/* v1 receives "abc" */
/* v2 receives "tu" */
/* v3 receives "z"" */
Nagaraju Domala
Quiz
line1 = '11:25:01'
Parse Var line1 hh ':' mm ':' ss
Nagaraju Domala
Quiz
/* hh receives "11" */
/* mm receives "25" */
/* ss receives "01" */
Nagaraju Domala
Lab Exercise III
Program Name
Author Name
Compiled Date
Nagaraju Domala