Using Template Processors in JCL w/Zowe CLI

Dan Kelosky
Zowe
Published in
3 min readMar 13, 2023

--

{Core} Note: Assuming basic familiarity and installed prerequisites of Node.js, npm, and Zowe CLI to follow along with this blog.

Here, we’ll break apart a previous blog to show how you can use JavaScript templating tools within JCL. Then, you can share your JCL with colleagues via something like a GitHub repo!

JavaScript Templating

The idea behind templating is simple. That is, you take an input document with placeholders identified via {{...}}, substitute with actual values from a data file, and output the result:

For JCL, we could substitute something like {{jobcard}} to be a given user’s JCL JOB header.

Create project + Dependencies

To get started, we’ll show how to use a popular templating engine called handlebars.

As an alternative to building this by hand, you can clone the repo.

Start by creating a directory on your workstation, e.g. mkdir handlebars-jcl. From there, initialize a npm project via npm init -y and install dependencies using npm install --save-dev handlebars config.

Script

In the root of the project, create a script to invoke handlebars, render.mjs:

Template

You must manually create two output directories out as well as a template. After creating those, you can create a sample template file in the template directory e.g. hello.txt with contents hello {{planet}}:

Data

The project is setup to use node-config. By default, data values will come from a folder you create called config. Within there, default.json5 can be used to specify defaults. You can also create a local.json5 in your config directory to override what is is default.json5 for user specific values:

Render

Run an example with node render.mjs hello.txt:

C:\dev\node\handlebars-jcl>node render.mjs hello.txt
wrote out/hello.txt

This takes the template and creates a new result:

Before and after

JCL

Similar to the above, you can can mark up JCL, for exampleiebcopy.jcl, with the items that you would like to substitute:

Before and after

Then you can create the data values that you want to substitute (where defaults come from default.json5 and overrides come from local.json5:

{
"jobHeader": [
"//IEBCOPY$ JOB IZUACCT,'DAN KELOSKY',",
"// MSGCLASS=A,CLASS=A,MSGLEVEL=(1,1),REGION=0M"
],
"in": "INPUT.DATA.SET",
"out": "OUPUT.DATA.SET",
"members": [
"IEFBR14",
"IEFBR15",
"IEFBR0"
]
}

Then use node render.mjs iebcopy.jcl to get:

Values substituted

Lastly, you can run the JCL via zowe jobs submit local-file out/iebcopy.jcl.

Now, you can share this with your new-to-mainframe teammates or add this technique for use in some Jenkins pipeline!

Summary

There are many development tools, such as templating processors, that do not have immediate application for mainframe development. However, by using Open Mainframe Project’s Zowe and the tooling it provides, you can quickly tie these tools to your mainframe projects!

Learn more

If you enjoyed this blog check out more Zowe blogs here. Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #zowe-api, #zowe-explorer-intellij, #zowe-explorer, #zowe-cli, #zowe-dev, #zowe-user, or #zowe-onboarding. If this is your first time using the Open Mainframe Slack Channel register here.

--

--

Dan Kelosky
Zowe

Likes programming/automation in mainframe (assembler, C/C++), distributed (Node.js), and web development (Firebase, Angular).