COBOL

from Wikipedia, the free encyclopedia
COBOL
Paradigms : Initially purely imperative, later expanded to include elements of structured , procedural and nowadays even object-oriented programming
Publishing year: 1959
Developer: Grace Hopper , William Selden , Gertrude Tierney , Howard Bromberg , Howard Discount , Vernon Reeves , Jean E. Sammet
Current  version : COBOL 2014  (2014)
Typing : strong , static
Dialects: DEC COBOL, HP COBOL, IBM OS / VS COBOL, IBM COBOL / II, IBM COBOL SAA, IBM Enterprise COBOL, IBM COBOL / 400, IBM ILE COBOL, Unix COBOL X / Open, Micro Focus COBOL, Microsoft COBOL, Ryan McFarland RM / COBOL, Ryan McFarland RM / COBOL-85, DOSVS COBOL, UNIVAC COBOL, Realia COBOL, Fujitsu COBOL, ACUCOBOL-GT
Influenced by: FLOW-MATIC , COMTRAN , FACT
Affected: PL / I , PL / SQL , ABAP
Operating system : z / OS , Windows , Linux , Mac OS X , BS2000 , OS / 400 and many more. m.

COBOL is a programming language that originated in the early days of computer development, in the late 1950s , and is still used today. The style of this programming language is based heavily on natural language and is primarily used for programming business applications.

The abbreviation COBOL stands for " Co mmon B usiness O riented L anguage".

story

COBOL was born out of the urgent need to have a hardware-independent, standardized, problem-oriented language for creating programs for the business sector. The programming of commercial applications differs from technical-scientific applications mainly in the handling of large amounts of data instead of the execution of extensive calculations. After the programming of technical and scientific applications had already been greatly simplified by FORTRAN , the new programming language was supposed to take greater account of commercial problems, in particular the handling of large amounts of data and their input and output, which until then had largely been programmed in assembly languages.

A working group set up by the American Department of Defense developed a standard from the combination of the programming languages FLOW-MATIC from Sperry Univac (Remington-Rand), Commercial Translator (COMTRAN) from IBM and FACT from Minneapolis-Honeywell. Grace M. Hopper , who had already developed FLOW-MATIC and the first compiler ( A-0 ), was particularly involved in this .

The result was adopted by CODASYL as COBOL-60 in 1960 , and was subsequently further developed and standardized by national and international standards institutes (ANSI, ISO).

COBOL quickly found its way into civil use as one of the first commercially used compilable programming languages ​​and is still one of the most widespread for commercial applications.

In 2020, there was renewed demand for COBOL developers in the USA when the unemployment figures skyrocketed in the wake of the corona pandemic , but the administrative systems of unemployment insurance in the US state of New Jersey were no longer able to cope with the demand.

Language syntax

Originally, COBOL was only written in capital letters, as only punch cards and line printers without lower case letters were available. Even today, no distinction is made between upper and lower case. COBOL is therefore case insensitive . A COBOL program is divided into parts ( DIVISION), chapters ( SECTION) and sections ( PARAGRAPH).

The four DIVISIONs are in their specified order:

  • Identification Division with the program name and some largely obsolete paragraphs for comments;
  • Environment Divisionwhere interfaces to the operating system and its file system are defined;
  • Data Division with the definition of the program variables and data structures and
  • Procedure Division with the procedural instructions.

In IDENTIFICATION DIVISIONthere is no SECTIONs, and in the PROCEDURE DIVISIONcan again SECTIONs and PARAGRAPHs accounts. ENVIRONMENTand DATA DIVISIONs can be omitted completely under certain circumstances.

This shows the strict separation of data declaration and procedural instructions that distinguishes COBOL. In the procedure part, you can only use variables that have been previously declared in the data section. The appearance of formatted output is not PICTUREspecified in the procedure judgment, but in the data section by the clause. This REPORT WRITERmakes it possible to describe the structure of a print list completely in the data part as a physical structure of pages and a logical structure of line items with group totals etc. without the procedural judgment having to worry about it.

Coding

The traditional coding scheme at COBOL corresponds to the punch card with its 80 columns, i.e. H. Writing places. The first 6 digits were reserved for the line numbering. Column 7 was reserved to identify a comment or a continuation line or one that is only to be translated for debugging. Columns 8 to 11 ( Area A ) contained the names of divisions, sections and paragraphs. Columns 12 to 72 ( Area B ) contained everything else, for example statements . Columns 73 to 80 were for other markings such as B. the name of the program or source code elements provided.

In addition to the fixed line format, which removes the division into Area A and Area B, the standards from 2002 onwards include a completely free format that allows everything in columns 1 to 255. The special role of the column 7 deleted because comments with *>initiated literals means &assembled and debugging lines are realized by means of conditional translation >>DEFINE … >>IF ….

An almost minimal COBOL program:

        Identification Division.
        Program-ID. HALLOPGM.
        Procedure Division.
            Display "Hallo Welt!".
            STOP RUN.

Data declarations

... take place in the data division

  • Files and their record structures are described in the File Section .
  • Static (global) variables are defined in the working storage section .
  • Automatic (local or dynamic) variables are defined in the local storage section . (see stack )
  • Call parameters are Linkage Sectiondefined in the.
  • Complex print lists are Report Sectiondefined in the.
  • Screen input and output in the Screen Section.

COBOL offers numerous clauses for declaring variables, the most important of which are the level number, the PICTURE clause and the USAGE clause.

Level number

The level number 77 identifies a free-standing variable. The level number 01 can also designate a free-standing variable, but normally introduces the declaration of a group - which is referred to in other languages ​​as a record ( Pascal etc.) or struct ( C ++ , C etc.). The level numbers 02 to 49 then identify subordinate data declarations to this group, which can themselves also be groups. A data declaration that has no subordinate data declarations (i.e. with higher level numbers) is referred to as elementary item in COBOL , otherwise it is a group variable (group item) . Such data declarations can be represented abstractly as a tree ; with the groups as nodes and the elementary items as leaves - to which data formats are assigned via the PIC clause.

With the special level number 66, whole memory areas can be given another name, with 88 a condition name can be defined, which can be used like a Boolean expression in an IF statement, for example.

The level numbers are usually written with two digits. From the times of punched cards, the habit stems from the fact that the level numbers in a group definition were not assigned consecutively, but in steps of 5 or 10, because you could then insert intermediate levels without having to punch a whole pile of cards again.

The following example describes the layout of the traditional 80-character COBOL program line:

  01  Cobol-Zeile USAGE DISPLAY.
      05  Zeilennummer        PIC 9(6).
      05  Indikator           PIC X.
          88  Ist-Kommentar         VALUES '*' '/'.
          88  Ist-Fortsetzungszeile VALUE '-'.
          88  Ist-Debuggingzeile    VALUE 'D' 'd'.
      05  Bereich-A-und-B.
          10  Bereich-A       PIC X(4).
          10  Bereich-B       PIC X(61).
      05  Zeilen-Endekennung  PIC X(8).

The definition of a value range looks like this as an example:

 01 Wertebereich          PIC 99V99 USAGE COMPUTATIONAL.
    88 Einerwerte         Value 1 thru 9.
    88 Zehnerwerte        Value 10 thru 19.
    88 Zwanzigerwerte     Value 20 thru 29.
Internal and external data format

External appearance and internal representation are essentially determined by the clauses PICTUREand USAGE. With USAGE COMPbinary calculation and comparison operations are performed, USAGE DISPLAYis used to display. Arithmetic operations and comparisons (less than / equal to / greater than ...) are USAGE COMP-3possible with directly.

The PICTUREnumber of digits / characters or editing symbols such as decimal or thousand separators, signs, currency symbols, imaginary decimal separator (V) etc. are specified with information after . You define an elementary variable as either alphabetical, alphanumerical, numerical or numerical-edited. If arithmetic operations (such as ADD BETRAG-X to SUMME-Yor IF DATUM-A > DATUM-B)variables with inconsistent numeric formats are involved), one or both of the data fields are automatically converted into a format that is valid (for the operation) before the operation.

The formatting for visible output is determined by the data declaration, not by procedural instructions as in languages ​​like Pascal or C. More of the approximately 60 possible clauses of a data declaration can be looked up in a COBOL manual.

Table formats

Data that occurs more than once (called 'tables' in COBOL, see field (data type) ) are defined by the OCCURS-clause; Example of a multi-dimensional table:

05 PRODUKT      OCCURS 100.
10 PRODUKTNR    PICTURE 999.
10 PRODUKTNAME  PICTURE X(30).
10 PREIS        PICTURE 999V99   OCCURS 5 INDEXED BY IND_KUNDENGRUPPE.

The Occurs clause is possible for each data group as well as for elementary fields. The respective dimension can alternatively be addressed using the index method (addition Indexed BY <IND-NAME>) or a subscript:

  • A 'Subscript' is the name of a (numeric) variable in the respective COBOL command (example:) MOVE PRODUKTNR (PNR) TO xx.
  • A, index contains the distance adjusted data to be addressed dimension to the beginning of the table and with a SET command explicitly to that value of: SET IND_KUNDENGRUPPE BY KUNDENGRP. The indexing is advantageous if several / many individual commands relate to the dimension to be addressed, because the main part of the address calculation does not take place for each command execution, but with SET .

The machine commands for calculating the distance of the dimension addressed by index / subscript to the beginning of the table {e. B. (PNR-1) * length (data group PRODUCT)} are automatically placed in front of the actual COBOL command (MOVE, IF etc.) and executed in both versions. In multi-dimensional tables (see example), both addressing methods can be used mixed.

With the addition DEPENDING ON xxx, the number of table elements can be variably defined.

Procedural instructions

The Procedure Divisionexecutable program code can be found in the. Execution begins with the first statement after the heading Procedure Divisionor those DECLARATIVESwhose execution is only triggered by certain events. After that, all statements are executed sequentially until one STOP RUNends the program or one GO TOor PERFORM(with a subsequent return) branches to another point in the program.

The procedure division consists of one or more procedures. A procedure is either

  • a section: denoted by a name that begins in column 8, followed by the keyword SECTIONand a period; usually contains several paragraphs.
  • a paragraph: denoted by a name that begins in column 8 and ends with a period.

Such a procedure contains the instructions of the COBOL program ( statements ).

Procedures can be Performexecuted / called from other places in the program with the COBOL instruction . With the addition THRU <proz-name>in the Perform statement, several procedures can be combined for execution. There is no formal parameter transfer, all procedures have access to all fields in the data division.

By CALLexternal programs (COBOL and other programming languages) can be called. Parameters By Reference or By Content (also called By Value depending on the COBOL version ) are transferred, which means, among other things. A distinction is made as to whether transferred parameter variables can be effectively changed by the called program for the calling program (by ref) or not (by content).

COBOL has supported structured programming since the 1974 standard (VS COBOL II) ; since then the use of 'GOTO' is still possible, but frowned upon. In-house programming standards prevail in professional programming, most of which stipulate that procedures consist exclusively of one section.

COBOL was designed with a syntax based on the English language to be 'self-documenting' and essentially easy to read even for non-programmers. All instructions begin with a verb (as in MOVE x TO y) reserved in the 'COBOL keywords' - in contrast to short notations (as y = x) in other modern programming languages.

Simple snippets of code

Simple C syntax is used to represent the syntax .

corresponds in COBOL MOVE b TO a
  • a = b + c
can be written in COBOL as follows: ADD b TO c GIVING a
or alternatively COMPUTE a = b + c
  • analogous b = a - 1to C
corresponds in COBOL SUBTRACT 1 FROM a GIVING b
corresponds in COBOL ADD 1 TO a
  • The decrement operator --ain C
corresponds in COBOL SUBTRACT 1 FROM a

IF / ELSE and EVALUATE

IF and ELSE work as expected. The End-If was only introduced with the COBOL85 standard. In the COBOL74 standard, the IF statement was ended by a period, which could be an easily overlooked source of error.

COBOL85 syntax:

    If Nenner > 0
         Compute Zahl = Zaehler / Nenner
         End-Compute
    Else
         Display "Nenner sollte > 0 sein!"
         Move 0 To Zahl
    End-If

COBOL68 syntax:

    If Nenner > 0
         Compute Zahl = Zaehler / Nenner
    Else
         Display "Nenner sollte > 0 sein!"
         Move 0 To Zahl.

EVALUATE makes the multiple case differentiation, with which every form of CASE or switch (as in C), sequences of IF / ELSIF / ELSIF / END-IF up to complete decision tables can be represented. The EVALUATE instruction was integrated into COBOL85 for the first time, COBOL versions prior to the 85 version do not recognize EVALUATE, so that multiple case distinctions had to be mapped there using IF constructs, some of which are difficult to read.

    Evaluate True
        When  Nenner > 0
              Compute Zahl = Zaehler / Nenner
        When  Nenner < 0
              Compute Zahl = Zaehler / Nenner * -1
        When Other
              Display "Nenner sollte nicht 0 sein!"
              Move 0 To Zaehler
    End-Evaluate

A COBOL specialty are the so-called conditional statements , these are COBOL statements with a condition clause:

COBOL85 syntax:

    Read Eingabesatz
         At End
             Display "Dateiende erreicht" Eingabe-Zaehler "gelesen!"
             Set Ende-der-Verarbeitung To True
         Not At End
             Add 1 to Eingabe-Zaehler
    End-read

grind

A C loop like " for (i=0; i<10; ++i) {...}" is coded in COBOL with PERFORM (COBOL85 syntax):

    Perform Varying i From 0 By 1
              Until i >= 10
       ...
    End-Perform

COBOL today

The main area of ​​application of the COBOL programming language is business data processing. If EDP programs are structured into a user interface, a processing part and a data management part, the main use of COBOL programs is in the processing part.

A large number of options can be used as a user interface, particularly on PCs, but also on other systems. In addition to the standard COBOL instructions ACCEPTfor keyboard input and DISPLAYscreen output, the X / OPEN specification SCREEN SECTIONalso includes manufacturer-specific solutions.

If the application architecture is divided into several layers, the presentation layer can also be shifted to the client. This allows access to COBOL applications via graphical front ends. Client and server must support a communication protocol for this. If such a system originally had to be developed manually, the SOA architecture patterns later provided corresponding standards.

The data management part can be implemented with COBOL means or with a database connection. COBOL provides embedded SQL (EXEC SQL) for access to relational databases . You can also program stored procedures in COBOL.

COBOL is used in the economy, especially in banks and insurance companies, and in administration, e.g. B. at the tax authorities, widespread. Due to the historical number of COBOL programs, it is very difficult and very expensive for companies to replace them. The main reason to be mentioned here is the lack of documentation ( software crisis ), but not the irreplaceability of COBOL.

Some of the innovations in COBOL over the last few decades - in brackets the standard that introduced this:

  • Nested Program (COBOL 85) allows procedures with local variables to be written within a COBOL program.
  • Intrinsic Functions (1989 Appendix to COBOL 85) for math and other functions.
  • The COBOL verb XML PARSE (proprietary) offers an integrated XML parser. There is also JSON PARSE for JSON .
  • OO extensions (COBOL 2002) made it easier to work with object-oriented programming languages.
  • Format-free notation (COBOL 2002) allows a line length of 255 characters and a waiver of the old margins A and B.
  • Conditional compilation (COBOL 2002) and preprocessing (proprietary).

Development and standardization

A committee of the above-mentioned CODASYL developed some principles in 1959, determined the name COBOL and published its final report in April 1960 with the first specifications of the programming language, which went down in history as COBOL-60.

Within the framework of CODASYL there was then a permanent committee, sometimes with sub-committees, which dealt with the further development of COBOL and had different names and different statuses within CODASYL over the decades.

Development by CODASYL

COBOL-60 demonstrated the practicality of the common programming language sought.

COBOL-61 was only partially compatible with the previous version, but was largely implemented in numerous compilers. CODASYL then committed itself to further developing the language evolutionarily from there, instead of making revolutionary changes.

With COBOL-61 EXTENDED came among others. the SORT options and the REPORT WRITER are added.

COBOL, EDITION 1965 added, inter alia internal tables and options for file processing added.

Further development documents are the CODASYL COBOL JOURNAL OF DEVELOPMENT from 1968, 1969, 1970, 1973, 1976, 1978, 1981 and 1984.

Extensions through X / Open , the Open Group

As part of the efforts for a standard for the Unix operating system by the industrial association X / Open, specifications for COBOL were also agreed, the most recent of which from 1991 consists of the highest levels of the prescribed modules of COBOL-85, with the expansion in 1989 by the " Intrinsic Functions ”, but without report writer, segmentation and debugging, but with its own extensions for interaction with screen forms (SCREEN SECTION and ACCEPT / DISPLAY), shared access to files with locks on files and records, as well as internationalization with e.g. B. Double-byte character sets.

Standardization through ANSI

In 1960, suggested by the industry association "Computer and Business Equipment Manufacturers Association", a "Committee on Computers and Information Processing" with the number X3 was created within the framework of the US standardization organization ( ASA ), which then became a subcommittee X3.4 for programming languages, which in turn set up a sub-committee X3.4.4 for COBOL. In December 1962, manufacturers and other interested parties were invited to collaborate on standardization, and it was then determined that the standardization should be based on the publications of CODASYL.

The first standard was adopted on August 23, 1968 as the USA Standard COBOL 1968 and published as Document X3.23-1968.

Committee X3.4.4 then became Technical Committee X3J4, as it is still called today, and set to work on developing the next standard, which was then passed on May 10, 1974 as the American National Standard COBOL 1974 and then in the document ANS X3.23-1974 was published.

The next standard was passed by X3J4 in April 1985 and adopted in September by the responsible decision-making body of the now ANSI organization and then published as ANS X3.23-1985. With delimiters such as END-IF and END-PERFORM, COBOL-85 introduced the possibility for the first time to write arbitrarily nested decision (IF, EVALUATE) and repetition instructions (PERFORM) in COBOL and thus to practice so-called structured programming in COBOL. An addendum with built-in (intrinsic) functions and another with corrections to the standard were later published for COBOL-85.

A new standard was adopted in 2002. The main changes are the adoption of the extensions by X / Open, the explicit support of international character sets including Unicode , object-oriented programming and conditional compilation, along with numerous other extensions and specifications.

After the end of CODASYL , Committee J4 took on responsibility not only for standardization, but also for development.

The next standard was prepared for 2010 and was published in 2014.

International standardization at ISO

Committee X3J4 (formerly X3.4.4) has worked closely with various international bodies from the start. Accordingly, ANS COBOL X3.23-1968 complied with the ISO recommendation for COBOL.

In the ISO, the Technical Committee ISO / TC 97, Computers and Information Processing is responsible, the secretariat of which is provided by ANSI.

ISO has passed a Recommendation R-1989: 1972 as well as the ISO 1989: 1978 and ISO 1989: 1985 standards for COBOL and adopted the specifications of the US standardization body.

In 2002 another standard was reversed, first published as ISO / IEC 1989: 2002 and then adopted by the national standards organizations.

The current standard was published in 2014 as ISO / IEC 1989: 2014.

Modules and standard-compliant implementations

COBOL-68, COBOL-74 and COBOL-85 assigned the various features of the language to a module with one to three "levels" each, from which minimal and full implementations of the standard were then defined as a combination of certain levels of the respective modules. An implementation that conforms to COBOL-2002 must implement the entire scope of the language.

COBOL compiler

For computers of the “ mainframe ” and “ medium-sized data technology ” classes , their respective manufacturers - IBM, Unisys, Siemens, Fujitsu-Siemens, HP, Bull and others - have offered and still offer. - COBOL compilers tailored to your proprietary operating systems, e.g. T. different compilers, which for example correspond to different standards.

There are COBOL compilers from various software manufacturers for operating systems that have emerged from the UNIX or MS-DOS tradition. GnuCOBOL is an open source implementation of the programming language.

COBOL generators

There are code generators that generate COBOL programs or parts of them and thus facilitate development work. These include, for example, SWT01 and SWT / VDA from the manufacturer FSP, CA Gen (formerly Cool: Gen) from CA Technologies , as well as the ADSplus and SCORE generator systems from Delta Software Technology.

literature

  • Franck Barbier, Jean-Luc Recoussine: COBOL Software Modernization , iSTE Wiley, 1st edition 2015, ISBN 1-84821-760-9
  • Michael Coughlan: Beginning COBOL for Programmers , Apress, 1st edition 2014, ISBN 1-4302-6253-2
  • Nancy B. Stern, Robert A. Stern and James P. Ley: COBOL for the 21st Century ,
    John Wiley & Sons, 11th edition 2013, ISBN 1-118-73953-1

Web links

Wiktionary: COBOL  - explanations of meanings, word origins, synonyms, translations
Commons : COBOL  - collection of images, videos and audio files

Individual evidence

  1. a b Kathrin Stoll: Senior programmer desperately wanted - for 60 years old programming language - t3n - digital pioneers. Retrieved on April 23, 2020 (German).
  2. WDR ( Memento from June 8, 2016 in the Internet Archive )
  3. ^ Grace Hopper , accessed June 8, 2016
  4. "Covid-19: Why Cobol programmers are suddenly needed again in the USA" the standard from April 6, 2020
  5. Manager Magazin: Programmers 70 or older urgently wanted , accessed on May 23, 2020.
  6. IT finance magazine; COBOL turns sixty - Evergreen with young talent , accessed on May 23, 2020.
  7. GnuCOBOL (formerly OpenCOBOL). Retrieved December 27, 2016 .