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!

3 thoughts on “MOM Pt. 003: Getting to know COBOL – Compiling

  1. Hi Kevin,
    In ch4 part3 I had the same issue, but Bob L from the mainframe slack gave me the answer: In SDSF try: prefix * and then: owner Z##### the name of the owner of the work.
    This should work in your MOM too!
    You tell me!

    1. Hi Georges,

      Interesting! Thanks for sharing! I’ll try this out, I had some trouble in the last MTM 19 challenges I have blogged about. I didn’t see my outputs but I knew what I was doing so I didn’t really need it. I guess you could say I was being lazy, heheh.

      – Kevin

  2. Things would be simpler if you change the jcl name from TESTCOB to something like HERC01C, where HERC01 is the user profile you are using

Leave a Reply

Your email address will not be published. Name, email and website not required.