In this episode of Coding with Kip, I demonstrate the results of a proof of concept work effort the summer of 2018, showing that using Scala on z/OS is possible. The video shows the following

  • GitHub can be used on the z/OS Unix System Services linux component.
  • Builds in this environment can be done using Maven.
  • The resulting Java JAR file can be executed in that environment, using standard linux commands.
  • The same JAR file can be executed on the z/OS side of the system, using JCL.
  • Scala can be coded to access the z/os Jzos module. Jzos modules allow java to access z/OS services natively, doing things like I/O using JCL datasets, and giving standard JCL return codes.
  • Scala modules can be used in the Application Performance Analyzer for z/OS to highlight performance implications.

This video gives an overview of the resulting system.

jZOS with Scala Sample Code

The following are elements that can be used in recreating this project.

Project Setup

The following dependency must be place in the POM file for the build to occur properly.

<dependency>
<groupId>com.ibm.jzos</groupId>
<artifactId>ibmjzos</artifactId>
<version>2.4.8</version>
</dependency>

Since jzos is not an open source component, you will need to import the JAR file into your project. You can download it from the z/OS environment you have access to, in the IBM delivered libraries.

In Module Set-up

At the top of the Scala module, you’ll need to import the jzos library with the following code.

import com.ibm.jzos._

You’ll also want to set the platform encoding with:

val encoding = ZUtil.getDefaultPlatformEncoding

Read Process

In order to create a receiving container for the data, we defined a Byte Array

var vendorHistoryCurrentData: Array[Byte] = null

And we defined the file as a RecordReader:

var vendorHistoryFileIterator: RecordReader = null

The following code reads the file

vendorHistoryFileIterator = RecordReader.newReader(ZFile.getSlashSlashQuotedDSN("Your file name here as a constant"),
  ZFileConstants.FLAG_DISP_SHR)
vendorHistoryCurrentData = new Array[Byte](vendorHistoryFileIterator.getLrecl)

You’ll also want to close the file when complete:

vendorHistoryFileIterator.close()

Write Process

The following creates a file to write to:

val vendorHistoryWriter = RecordWriter.newWriter(
  ZFile.getSlashSlashQuotedDSN("your file name as a constant here"),ZFileConstants.FLAG_DISP_SHR)

You’ll also want to close the file:

vendorHistoryWriter.close()

This is another episode of Coding with Kip, the technical sub-series of Conversations with Kip, the best financial system vlog there is. Literally learn more–about ledgers and financial systems–at LedgerLearning.com.

Watch the series in order at the Coding with Kip Playlist.