MOM Pt. 003: Getting to know COBOL – Compiling

Today I’m going to get to know COBOL. I’ve already used COBOL in IBM’s Master the Mainframe 2018 contest, but this time I’m working in MVS 3.8!

What am I planning to do here? Well, before I start learning COBOL I want to know how I can edit, compile and run it on my own mainframe. MVS3.8 provides a small piece of test code in SYS2.JCLLIB called TESTCOB.

So I go to RFE. Then I need to navigate in the DSLIST utility, so that means I enter 3.4 to quickly get there. The data set name prefix is SYS2.JCLLIB. When editing, I am able to scroll down and edit TESTCOB.

So this is TESTCOB. Normally any piece of COBOL production code has four divisions.

    • Here we identify the COBOL program, the name of the program itself. Typically, the program documentation goes here.
    • Here we link the program with external data sets.
    • Here we define the local variables, exclusive to this program only.
    • Here we code all our logic.

As you can see on the image below, TESTCOB indeed has the four divisions.

Now what have I highlighted in pink? Those are sections. Sections can be omitted but they have chosen not to in this case. At line 000027 you can see 000-DISPLAY, that is a routine. The next two lines are statements/sentences inside a paragraph. These state that the machine needs to DISPLAY the HELLO-CONST in CNSL. The HELLO-CONST is defined at line 000025 in the data division. CNSL is an alias for CONSOLE defined in the CONFIGURATION section. The code pretty much speaks for itself right? Display HELLO, WORLD in the console and then STOP running.

Now what is HELLO-CONST PIC X(12) VALUE ‘HELLO, WORLD’? This means that HELLO-CONST can carry 12 bytes. 1 byte equals to 1 character in an EBCDIC mainframe. You can see as a template, in theory HELLO-CONST is XXXXXXXXXXXX. We fill those X’s with ‘HELLO, WORLD’, X means the repetition factor meaning X is repeated 12 times.

SPOILER ALERT: change MSGCLASS=A to MSGCLASS=H on line 000004!

When you’re finished checking this file, enter the primary command save to save your changes. To execute your program, enter the primary command submit.


To check our output we need to go back to the root RFE and navigate to the OUTLIST (3.8). Select the correct job by using the line command s.

Kevin’s Coding Blog is experiencing technical difficulties

It’s not here? Where is it? The COBOL job isn’t outputting to the OUTLIST?

Please allow me to add some Google tags for those with the same issue: cobol mainframe MVS 3.8 tk4 no job output help sysprint please google.

I forgot to change the MSGCLASS to H. This means you want the output from the compiler to be held. Now let’s submit it again and check the output.


Yes I know, 25… I’ve been struggling. Again the job output was empty, but after entering the primary command ST * I can see all the jobs.

TESTCOB is there! Now I’ll select with s and see what it did.

There it is! HELLO, WORLD. We have done it!

Next up: our own custom mix of JCL and COBOL!

Are you experiencing any technical difficulties?

Tell me all about it!

Share this:

MOM Pt. 001: Setting up my own Mainframe!


It’s been two months since my last blog post, that’s bad! I took a break after participating in master the mainframe as it took a lot of time and energy away from me. I was not only active here on my blog but also on Slack and LinkedIn; I helped out a lot of students/enthusiasts with the challenges. But now… I’m back, alive and well.

So, I’m setting up my own mainframe today. I know I can still use the mainframe IBM has made publicly available to all Master the Mainframe contestants. But having my own mainframe is way more fun isn’t it? I can’t run z/OS as I would need a valid license.

I have two options:

  • VM/370 by IBM is the last public domain mainframe platform available.
  • MVS 3.8j Tur(n)key 4- System, no SQL available.

I will try MVS 3.8j. The only downside I really see with using one of these is that there’s no SQL-like driver available. The only good reason I have to use these systems is so I could develop COBOL and ASM directly inside a mainframe. It’s also a lot of fun!

I’ll definitely do some DB2 and COBOL later using IBM’s mainframe. I’m also unsure whether I’ll learn Java mixed with COBOL, that’s an option for the future.

So I was looking around on the internet and I stumbled upon a presentation by Jeroen Baten. He didn’t really explain how to setup a mainframe on Linux but he did give a clear statement.

So, I’ll do exactly what Mr. Baten said.

Building Hercules from source

I’ll be doing this on Debian 9, as it is the operating system I’ll be running on Hetzner (a cloud host provider). There’s only 7 simple steps to follow.

  1. Download the source code to your system using wget: wget
  2. Unzip using: tar xvzf release-3.13.tar.gz
  3. Run: ./util/bldlvlck and see which dependencies you need to install. Besides all listed dependencies you’ll also need to install g++ by issuing apt install g++. If you can’t execute the file then chmod u+x ./util/bldlvlck so you can execute the file.
  4. Then generate the configuration file using ./
  5. Then configure using ./configure.
  6. Then create the executables using make.
  7. Then install the programs as root using make install.

This should be simple right? Right? Right… Also, the reason I’m getting the files from GitHub is because the autogen script is missing from the official download link. What’s up with that?! HUH?!

But… but… there’s also apt install hercules. I like building this from source. Just because.

So I have downloaded the files and extracted it to the spinhawk-release-3.13 folder. Now I can check which utils I still need to install.

I still lack autoconf, gawk, gcc, m4, make and g++. I’ll install those using apt install autoconf gawk gcc m4 make g++. When running the check util again it gives me OK for all requirements.

This means I can now generate a configuration file.

After generating the configuration file, I can let it configure by using ./configure and then I can make and make install. This might take a while.

Libraries have been installed in: /usr/local/lib/hercules. There! It’s done!

MVS 3.8j Tur(n)key 4-

This is easier than compiling Hercules. Actually, I don’t think setting up the Hercules emulator was necessary. I did it anyway. There’s also a Docker image available, but that’s not any fun either.

There’s only a few steps to do:

  1. wget
  2. wget (optional)
  3. wget (optional)
  4. unzip and then unzip the other zip files using the -o flag. Observe the screenshot below. It’s best to do this in a different folder.
  5. ./mvs

Getting the files.

Unzipping the files.

We’re going to set the MVS OS to console mode instead of daemon mode. This enables us to issue commands without being connected using a telnet connection. This can be done by changing to the unattended directory and running the  ./set_console_mode script.

Before we start the system, there’s a few things we need to know. Let me list it for you:

  • HERC01 is a fully authorized user with full access to the RAKF users and profiles
    tables. The logon password is CUL8TR.
  • HERC02 is a fully authorized user without access to the RAKF users and profiles
    tables. The logon password is CUL8TR.
  • HERC03 is a regular user. The logon password is PASS4U.
  • HERC04 is a regular user. The logon password is PASS4U.
  • IBMUSER is a fully authorized user without access to the RAKF users and profiles
    tables. The logon password is IBMPASS. This account is meant to be used for recovery purposes only
  • The IP address of the system. In this case I don’t need to port forward, it’ll also be a local IP address. You can discover the address by issuing ip addr show inside the terminal. Then you connect to that IP address using your 3270 terminal emulator. The port is 3270, not 23.

My address in this case is and port 3270. I’ll start the mainframe OS using ./mvs.

MVS is up and running!

Connecting to my mainframe

I know, I know, I shouldn’t be using Vista TN3270. When I can, I’ll buy a copy. I’m still using the license from IBM’s Master the Mainframe challenge.

So I’m connecting to the IP above and I’ve set the IP Port to 3270.

Let’s connect!

It’s alive! Enter the LOGON command. I’ll login as HERC03 and my password is PASS4U.

Everything is now setup and I’m ready to start writing my own COBOL!

What about you?

Are you running your own mainframe? Do you want to? If you don’t like mainframes then let me know at 

Let’s make our custom home screen in MOM part two!

Share this: