Finding the Number of Stacks

To find out how many stacks exist, use the TSO/E REXX QSTACK command. QSTACK returns in the REXX special variable RC, the total number of stacks including the original data stack.
'NEWSTACK'
⋮
'NEWSTACK'
⋮
'QSTACK'
SAY 'The number of stacks is' RC                  /* RC contains 3 */

QSTACK returns the total number of stacks, not just the ones created for a single exec. Thus if an exec issued two NEWSTACK commands and called a routine that issued two more, when the routine issues a QSTACK command, RC returns the total number of stacks, which is five.

For more information about these commands, see z/OS TSO/E REXX Reference.