Streamline your mainframe development with Open Mainframe Project’s Zowe Explorer & Zowe CLI (a series): Part 3 — REXX

Alex Dumitru
Zowe
Published in
4 min readAug 25, 2020

{Core} If you’ve read the other articles in this series, then you already have a pretty good idea what this recipe will be about. If not, here is the gist:

The end goal is to automate as much as possible and reduce the time to feedback during our development on mainframe using Visual Studio Code.

Dan Kelosky has done an awesome job in his article, showing us how to call a REXX script with the help of Zowe CLI. This one is meant to be the next step, by bringing this capability to VS Code. If you feel you are missing some details, please start by reading Dan’s article.

I am going to follow the same scenarios:

  • non-interactive REXX script
  • interactive REXX script

Non-Interactive REXX script

Being a non-interactive script it’s easier to implement because we don’t need to take user input into account.

Drawing from previous articles, we are going to build 3 artifacts:

  • a Powershell script
  • a VS Code task, to start off the script with required parameters
  • a key bind, to facilitate triggering the task

The “workhorse” comes first, our script that handles everything:

You might notice, compared to previous use-cases, now we use a second profile. The TSO profile is needed because it contains information used for creating the TSO address space. An in-depth look at TSO and Zowe CLI can be found in Joe Winchester’s excellent article.

Also, the error handling changed a bit, by using regex matching, just so it can properly capture REXX output.

I’ve also added a new REXX related section in my param.json file, to make parameterization easier, but other than that, the core idea is the same.

With the script completed, next comes the task definition (nothing out of the ordinary here):

And last but not least, the key binding to be able to easily trigger the automation:

End result, as expected, is pretty straightforward:

Interactive REXX script

Now let’s take a quick look at the interactive scenario.

By using the REXX PULL command, we are able to take input from the user. This means that the script will stop and wait for the user to type something at the prompt and continue after the ENTER key is pressed. This behavior changes things a bit, as you will see in our powershell script.

As you can see, this time we have to open a TSO address space ourselves and issue the commands there, and with the help of a simple for loop, we can respond to the prompts programmatically. When we are done, we have to manually close that address space.

A little piece of trivia for you! The command “zowe tso issue command xxx“ is doing the same thing behind the scene.

You might have noticed already, but I stored my inputs in params.json as an array, so make sure these are matching your REXX prompts, since they will be passed sequentially, or you have matching conditional processing (as I do). Alternatively, you can answer each prompt individually, using the same zowe tso send address-space foo --data bar command.

One other change I had to make was to move the error handling to its own function, so that I can easily use it for each Zowe command:

Finally, the task definition and the key bind are almost identical with what we created earlier. The only difference is the script name and the actual key combination used:

Final outcome, which can also handle basic conditional processing. Neat!
And for anyone who wonders, yes, my name is also Paul 😄.

I hope you will put this to good use, and to sweeten the pot even more, there is a REXX language support extension for VS Code out. You can read about it in Dana Boudreau’s article.

If you enjoyed this blog checkout more Zowe blogs here. Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #Zowe-dev, #Zowe-user or #Zowe-onboarding. If this is your first time using the OMP slack channel register here.

This blog is part 3 of “Streamline your mainframe development with Zowe Explorer & Zowe CLI (a series)”.

Full list:

--

--

Alex Dumitru
Zowe
Writer for

Software Developer at Broadcom and Zowe Project Contributor.