Cobol and Mainframe

What is COBOL

In this article, we will discuss about the introduction and fundamentals of the COBOL language. COBOL stands for Common Business Oriented Language. COBOL is especially mostly use for the large volume of application, and the transaction processing of billions of business transactions wherever it is.

Where Exactly Can We See COBOL Today?

  • COBOL programming language plays a crucial role in ATM systems as it is utilized in nearly 95% of all card transactions that are made at ATMs.
  • COBOL plays a crucial role in the majority of in-person transactions with an estimated 80% utilization of the programming language.
  • On a daily basis, COBOL systems facilitate approximately three trillion dollars in commerce.
  • On a daily basis, the number of COBOL transactions that is carried out is 200 times higher than the number of Google searches performed.

Features of COBOL

  • It is a programming language that follows a structured approach.
  • It is written in English version which makes it easy to understand.
  • It is easy to maintain all the aspects of its hardware and software.
  • It has a very high computing capacity.
  • In the prospect of application programs, it is easier to understand.
  • It has more readability of application program.

Types of COBOL

  • PC-based COBOL
    1. Small size applications
    2. MF COBOL (windows)
    3. IDE (open IDE) GNUCOBOL COMPILER
  • Real mainframe COBOL vs COBOL KS (visualize source) COBOL
    1. Large size applications
    2. VS- COBOL II

Installing COBOL on Local Machine

To install COBOL on Ubuntu/Linux, we have to follow these simple steps:

First, update “apt” database in the terminal.

Then, to install COBOL on the machine, use this command:

Finally, to check the COBOL installation, use this command:

Coding Sheet

This is the coding standard that we have to follow in our programming:

  • 1 – 6 pages / lines number – optional (automatically assigned by compiler)
  • 7 continuities (-), command (*), starting a new page (/)
  • Debugging line (D)
  • 8 – 11 Column A – Divisions, Sections, Paragraphs, 01, 77 declarations should start here
  • 12 – 72 Column B – All other statements and declarations start from this point.
  • 73-80 identification field which is visible in the source listing but is ignored by the compiler

Language Structure

The COBOL language is used to build the programs to develop applications. The programs are mainly divided into four divisions:

Identification Division:

It’s the first division and the program is identified here. As a mandatory element, the PROGRAMID followed by a user-defined name, must be included in the paragraph. The other paragraphs in the program are optional and serve the purpose of documentation.

  1. Identification Division
  2. PROGRAMID, PROGRAM NAME
  3. AUTHOR, COMMENT ENTRY
  4. DATE WRITTEN, COMMENT ENTRY
  5. DATE COMPILED, COMMENT ENTRY
  6. SECURITY, SOMMENT ENTRY

Environment Division:

The name itself indicates that it’s related to the environment like hardware, computer, and files that are used. It has two sections: the Configuration Section (the program where it is compiled) and the Input Output Section (the files that are used in the program).

  • FILE-CONTROL
  • I-O CONTROL

Data Division:

It is part of CBL PGM where every data item is processed by the program. Before using the data in the Procedure Division, it must first be declared in this section. The application is nothing but the data which is divided as temporary and permanent.

Temp: This variable is accessible throughout the execution of the program.

Perm: It is available after the completion of the program.

  • File Section
  • Working Storage Section
  • Linage Section

Working Storage Section:
It is mainly used to declare the user-defined variables or data names.

Naming Standards:

  • The variable name must consist of 1-30 alphanumeric characters.
  • It should contain at least one alphabet.
  • No space between characters.
  • No reversed words to be used like TIME, ADD, COMPUTE.
  • No special characters like # and $.
  • Example: WS-EMPNO, WS-EMPNAME

Basic COBOL Programs

Programming Example 1:

identification division.
program-id. "hello".

procedure division.
display "Learning COBOL is very fun!".
stop run.

Output:

papan@ubuntu : ~/Desktop/pp$ cobc -xjF pk.cbl
Learning COBOL is very fun!
papan@ubuntu: ~/Desktop/pp$

Explanation:
In this first example, we are trying to show you how a basic COBOL program is compiled and run. Here, we give the “hello” value as a program-id. Then, we print a simple line which is “Learning COBOL is very fun!” under the procedure division.

Programming Example 2:

DENTIFICATION DIVISION
PROGRAM-ID.  “addition_of_2_number”.
DATA DIVISION.
WORKING-STORAGE SECTION.

       77 X PIC 9 (4).
       77 Y PIC 9 (4).
       77 Z PIC 9 (4).
       PROCEDURE DIVISION.
       PARA.
DISPLAY " Please X's value= ".
ACCEPT X.
DISPLAY " Please Y's value= ".
ACCEPT Y.
COMPUTE Z = X + Y.
DISPLAY " Addition of X and Y is= ".
DISPLAY Z.
STOP RUN.

Output:

papan@ubuntu: ~/Desktop/pp$ cobc -xjF kk.cbl
Please X's value=
55
Please Y'
s value=
5
Addition of X and Y is=
0060
papan@ubuntu: ~/Desktop/pp$

Explanation:
Here, we give another demo programming example where we simply show a result of adding two numbers. For this, we take three variables – X, Y, and Z – under the working storage section. We take the values from the user and keep it inside the X and Y variables under the procedure division section. Then, we simply add these two numbers and assign them inside the Z variable.

Conclusion

In this topic, we cover all the aspects and the basics of COBOL. We hope that you are able to understand all the fields of the COBOL language so that you can easily implement the basic COBOL knowledge in the practical world or any real project.

About the author

Bamdeb Ghosh

Bamdeb Ghosh is having hands-on experience in Wireless networking domain.He's an expert in Wireshark capture analysis on Wireless or Wired Networking along with knowledge of Android, Bluetooth, Linux commands and python. Follow his site: wifisharks.com