COBOL

Introduction

COBOL is a Common Business Oriented Language. It is a high-level programming language. As the expanded acronym suggests, COBOL is designed for developing business, typically file-oriented applications.

COBOL is used by the US Department of Defense, in a conference, formed CODASYL (Conference on Data Systems Language) to develop a language. COBOL is used for writing application programs, and we can’t use it to write system software. This means you would not develop an operating system or a compiler using COBOL.

History of COBOL

COBOL language was one of the earliest high-level programming languages. During the 1950s, when the businesses were rising in the western part of the world, there was a need to automate various processes for ease of operation, and this gave birth to a high-level programming language destined for business data processing.

  • In 1959, the COBOL language was developed by Conference on Data Systems Languages (CODASYL).
  • The government printing office printed the COBOL specification as COBOL60 in 1960.
  • COBOL-61, which is the next version of COBOL, was released in 1961 with some revisions.
  • In 1968, COBOL was approved by ANSI (American National Standards Institute) as a standard language for commercial use. A version named COBOL-68.
  • It was again revised in 1974 and 1985 to develop subsequent versions that contain an additional set of features named COBOL-74 and COBOL-85, respectively.
  • And finally, in 2002, object-oriented COBOL was released, which could use encapsulated objects as a normal part of COBOL programming.

CHARACTERISTICS OF COBOL APPLICATIONS

Analysis suggests that the two areas of standard COBOL that take up most run-time are input-output (access to disk) and loops (formed by PERFORM and GO TO statements). Input-output is most crucial, however, once that is addressed there must be parallelism within the code to exploit the I/O parallelism.

Most COBOL applications fit into one of two categories:

  1. On-line transaction processing (OLTP): where inter-transaction parallelism is exploited to allow several instances of the program to run concurrently (subject to database locks etc.) on independent transactions.OLTP programs are typically executed in parallel by the Transaction Processing monitor (e.g. CICS, Tuxedo, TPMS) within which they are developed and executed. In these cases intra-transaction parallelism often comes as a by-product of the underlying RDBMS. As a result, there is little performance improvement likely for such applications. Nonetheless, there is potential for improvement.
  2. Batch: where the larger programs tend to handle serially a large number of records, subjecting them to similar processing. This is the read-modify-write loop used in many COBOL programs. Analysis suggests that most execution time is spent within these loops, as a result. they represent a major target for performance-enhancement.For many organisations, the overall runtime of their batch programs is a major operational issue. It means they need to size their systems on the basis of single stream performance rather than aggregate performance and to avoid this they often split work (manually) into separate runs (e.g. by initial letter of customer surname) which can be executed concurrently. In many case this “batch processing window” takes up all the time available between OLTP work. A relatively small improvement here would be significant.

The similarity between database processing and COBOL applications is indicated by their access to large datasets held on disk. Techniques used by parallel database implementations to minimise disk access by caching, and using distributed file-stores to increase concurrency will be of use for parallel COBOL implementation.

Installing COBOL on Windows/Linux

There are many Free Mainframe Emulators available for Windows which can be used to write and learn simple COBOL programs.

One such emulator is Hercules, which can be easily installed on Windows by following a few simple steps as given below −

  • Download and install the Hercules emulator, which is available from the Hercules’ home site: www.hercules-390.eu
  • Once you have installed the package on Windows machine, it will create a folder like C:/hercules/mvs/cobol.
  • Run the Command Prompt (CMD) and reach the directory C:/hercules/mvs/cobol on CMD.
  • The complete guide on various commands to write and execute a JCL and COBOL programs can be found at:

Hercules is an open-source software implementation of the mainframe System/370 and ESA/390 architectures, in addition to the latest 64-bit z/Architecture. Hercules runs under Linux, Windows, Solaris, FreeBSD, and Mac OS X.

A user can connect to a mainframe server in a number of ways such as thin client, dummy terminal, Virtual Client System (VCS), or Virtual Desktop System (VDS). Every valid user is given a login id to enter into the Z/OS interface (TSO/E or ISPF).

Compiling COBOL Programs

In order to execute a COBOL program in batch mode using JCL, the program needs to be compiled, and a load module is created with all the sub-programs. The JCL uses the load module and not the actual program at the time of execution. The load libraries are concatenated and given to the JCL at the time of execution using JCLLIB or STEPLIB.

There are many mainframe compiler utilities available to compile a COBOL program. Some corporate companies use Change Management tools like Endevor, which compiles and stores every version of the program. This is useful in tracking the changes made to the program.

//COMPILE   JOB ,CLASS=6,MSGCLASS=X,NOTIFY=&SYSUID             
//*            
//STEP1     EXEC IGYCRCTL,PARM=RMODE,DYNAM,SSRANGE
//SYSIN     DD DSN=MYDATA.URMI.SOURCES(MYCOBB),DISP=SHR
//SYSLIB    DD DSN=MYDATA.URMI.COPYBOOK(MYCOPY),DISP=SHR
//SYSLMOD   DD DSN=MYDATA.URMI.LOAD(MYCOBB),DISP=SHR
//SYSPRINT  DD SYSOUT=*
//*

IGYCRCTL is an IBM COBOL compiler utility. The compiler options are passed using the PARM parameter. In the above example, RMODE instructs the compiler to use relative addressing mode in the program. The COBOL program is passed using the SYSIN parameter. Copybook is the library used by the program in SYSLIB.

Executing COBOL Programs

Given below is a JCL example where the program MYPROG is executed using the input file MYDATA.URMI.INPUT and produces two output files written to the spool.

//COBBSTEP  JOB CLASS=6,NOTIFY=&SYSUID
//
//STEP10    EXEC PGM=MYPROG,PARM=ACCT5000
//STEPLIB   DD DSN=MYDATA.URMI.LOADLIB,DISP=SHR
//INPUT1    DD DSN=MYDATA.URMI.INPUT,DISP=SHR
//OUT1      DD SYSOUT=*
//OUT2      DD SYSOUT=*
//SYSIN     DD *
//CUST1     1000
//CUST2     1001
/*

The load module of MYPROG is located in MYDATA.URMI.LOADLIB. This is important to note that the above JCL can be used for a non-DB2 COBOL module only.

Executing COBOL-DB2 programs

For running a COBOL-DB2 program, a specialized IBM utility is used in the JCL and the program; DB2 region and required parameters are passed as input to the utility.

The steps followed in running a COBOL-DB2 program are as follows −

  • When a COBOL-DB2 program is compiled, a DBRM (Database Request Module) is created along with the load module. The DBRM contains the SQL statements of the COBOL programs with its syntax checked to be correct.
  • The DBRM is bound to the DB2 region (environment) in which the COBOL will run. This can be done using the IKJEFT01 utility in a JCL.
  • After the bind step, the COBOL-DB2 program is run using IKJEFT01 (again) with the load library and the DBRM library as the input to the JCL
//STEP001  EXEC PGM=IKJEFT01
//*
//STEPLIB  DD DSN=MYDATA.URMI.DBRMLIB,DISP=SHR
//*
//input files
//output files
//SYSPRINT DD SYSOUT=*
//SYSABOUT DD SYSOUT=*
//SYSDBOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DISPLAY  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
   DSN SYSTEM(SSID)
   RUN PROGRAM(MYCOBB) PLAN(PLANNAME) PARM(parameters to cobol program) -
   LIB('MYDATA.URMI.LOADLIB')
   END
/*

In the above example, MYCOBB is the COBOL-DB2 program run using IKJEFT01. Please note that the program name, DB2 Sub-System Id (SSID), and DB2 Plan name are passed within the SYSTSIN DD statement. The DBRM library is specified in the STEPLIB.

Design a site like this with WordPress.com
Get started