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

This video gives an overview of the resulting system.

https://youtu.be/sgZyDtyFgW4

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 = 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(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.

← All Posts