The Data Monster Under my bed : Migrating Cobol to the cloud – Part 4: Our First Program, build and run it … on docker

Lets do it quick

From this article we will start learning COBOL in step by step approach with smaller hands on examples.

The prerequisites we will need:

So lets begin

From the last article, we know that we have several mandatory divisions and minimal scope in order to write our first program.

Those are:

  • Identification division with minimum of program id in it
  • Procedure division with some statements in it

In order to display the trivial “HELLO WORLD” we will need to learn only one statement, called DISPLAY.

For now as beginning the only thing to remember is that the display statement is that it invokes data to be transferred to a given resource (hardware or software) of the operating environment. By default will display the output in the console

So here is the example code block:

Example Hello World COBOL program (hello.cob)

We have the code, now lets compile it

In order to compile the program we will need a build environment, that we will use initially for our build and explore process, and later on for the CI/CD pipelines we will create.

We will create a Dockerfile where we will compile and afterwards run the program we created. For that reason using the following public image:

thecharge/sndv:cobol-builder

The image is minimal Alpine linux with GnuCOBOL 3.1.2.0 environment you can use for your exploration and local environment.

Now lets build the image:

And run it:

The codebase for this article, is available for my patrons on PATREON

TO BE CONTINUED …