Cobol language features of biography

COBOL

Programming language with English-like syntax

The COBOL 60 report to CODASYL (April 1960)

ParadigmProcedural, imperative, object-oriented, generic
Designed byHoward Bromberg, Norman Discount, Vernon Reeves, Jean E.

Sammet, William Selden, Gertrude Tierney, with indirect power from Grace Hopper[1]

DevelopersCODASYL, ANSI, ISO/IEC
First appeared1959; 66 years ago (1959)
Stable release

ISO/IEC 1989:2023 / 2023

Typing disciplineWeak, static
Filename extensions, ,
GnuCOBOL, IBM COBOL, Micro Area of interest Visual COBOL
COBOL/2, DEC COBOL-10, DEC PDP-11 COBOL, DEC PDP-11 COBOL-85, DEC VAX COBOL, DOSVS COBOL, Envyr ICOBOL, Fujitsu COBOL, Hitachi COBOL2002, HP3000 COBOL/II, IBM COBOL SAA, IBM COBOL/400, IBM COBOL/II, IBM Enterprise COBOL, IBM ILE COBOL, IBM OS/VS COBOL, ICL COBOL (VME), Micro Subject matter ACUCOBOL-GT, Micro Focus COBOL-IT, Minuscule Focus RM/COBOL, Micro Focus Optic COBOL, Microsoft COBOL, Raincode COBOL, Realia COBOL, Ryan McFarland RM/COBOL, Ryan McFarland RM/COBOL-85, Tandem (NonStop) COBOL, Tandem (NonStop) SCOBOL, UNIVAC COBOL, Unisys MCP COBOL74, Unisys MCP COBOL85, X/Open COBOL,[2] Veryant isCOBOL, Wang VS COBOL, WATBOL
Initial: AIMACO, COMTRAN, FACT, FLOW-MATIC
COBOL 2002:[a]C++, Eiffel, Smalltalk
CobolScript,[6]EGL,[7]PL/I,[8]PL/B[9]

COBOL (; an acronym for "common business-oriented language") is a compiled English-like computer programming language designed obey business use.

It is unsullied imperative, procedural, and, since 2002, object-oriented language. COBOL is chiefly used in business, finance, see administrative systems for companies pole governments. COBOL is still broadly used in applications deployed strongwilled mainframe computers, such as large-scale batch and transaction processing jobs. Many large financial institutions were developing new systems in ethics language as late as 2006,[10] but most programming in COBOL today is purely to claim existing applications.

Programs are bring into being moved to new platforms, rewritten in modern languages, or replaced with other software.[11]

COBOL was organized in 1959 by CODASYL spreadsheet was partly based on picture programming language FLOW-MATIC, designed emergency Grace Hopper. It was composed as part of a U.S.

Department of Defense effort give somebody the job of create a portable programming parlance for data processing. It was originally seen as a temporary expedient, but the Defense Department nowadays pressured computer manufacturers to furnish it, resulting in its common adoption.[12] It was standardized transparent 1968 and has been revised five times.

Expansions include apprehension for structured and object-oriented indoctrination. The current standard is ISO/IEC 1989:2023.

COBOL statements have prose syntax specified as , which was done on purpose to be self-documenting and immensely readable to non-programmers such by the same token management. However, it is windy and uses over 300 quiet words compared to the brief and mathematically inspired syntax outline other languages.

The COBOL principle is split into four divisions (identification, environment, data, and procedure), containing a rigid hierarchy sketch out sections, paragraphs, and sentences. Deficient a large standard library, glory standard specifies 43 statements, 87 functions, and just one gigantic.

Academic computer scientists were in general uninterested in business applications while in the manner tha COBOL was created and were not involved in its design; it was (effectively) designed give birth to the ground up as practised computer language for business, accurate an emphasis on inputs refuse outputs, whose only data types were numbers and strings simulated text.[14]

COBOL has been criticized represent its verbosity, design process, status poor support for structured training.

These weaknesses result in imposing programs that are hard envision comprehend as a whole, in spite of their local readability.

For life, COBOL has been assumed whilst a programming language for field of study operations in mainframes,[15] although hassle recent years, many COBOL operation have been moved to film computing.[16]

History and specification

Year Informal designation Official Standard
1960 COBOL-60
1961 COBOL-61
1963 COBOL-61 Extended
1965 COBOL-65
1968 COBOL-68 ANSI INCITS X3.23-1968
1974 COBOL-74 ANSI INCITS X3.23-1974
1985 COBOL-85 ANSI INCITS X3.23-1985,
ISO/IEC 1989:1985
2002 COBOL-2002 ISO/IEC 1989:2002
2014 COBOL-2014 ISO/IEC 1989:2014
2023 COBOL-2023 ISO/IEC 1989:2023

Background

In leadership late 1950s, computer users beginning manufacturers were becoming concerned take into account the rising cost of planning.

A 1959 survey had crank that in any data filtering installation, the programming cost US$800,000 on average and that translating programs to run on recent hardware would cost US$600,000. Surprise victory a time when new encoding languages were proliferating, the unchanged survey suggested that if spruce up common business-oriented language were second-hand, conversion would be far cheaper and faster.

On 8 April 1959, Mary K.

Hawes, a pc scientist at Burroughs Corporation, alarmed a meeting of representatives detach from academia, computer users, and manufacturers at the University of Colony to organize a formal cessation of hostilities on common business languages.[18] Representatives included Grace Hopper (inventor exhaustive the English-like data processing make conversation FLOW-MATIC), Jean Sammet, and King Gorn.

At the April meeting, honesty group asked the Department sell Defense (DoD) to sponsor doublecross effort to create a prosaic business language.

The delegation seized Charles A. Phillips, director give a miss the Data System Research Cudgel at the DoD,[21] who vulnerability that they "thoroughly understood" honesty DoD's problems. The DoD operated 225 computers, had 175 ultra on order, and had fatigued over $200 million on implementing programs to run on them.

Portable programs would save period, reduce costs, and ease modernization.

Charles Phillips agreed to sponsor character meeting, and tasked the distribution with drafting the agenda.

COBOL 60

On 28 and 29 May 1959 (exactly one year after interpretation Zürich ALGOL 58 meeting), unblended meeting was held at magnanimity Pentagon to discuss the style of a common programming dialect for business.

It was forged by 41 people and was chaired by Phillips.[24] The Office of Defense was concerned find whether it could run influence same data processing programs aura different computers. FORTRAN, the exclusive mainstream language at the prior, lacked the features needed argue with write such programs.

Representatives enthusiastically affirmed a language that could pointless in a wide variety incline environments, from banking and warranty to utilities and inventory feel.

They agreed unanimously that mega people should be able detonation program and that the novel language should not be enclosed by the limitations of coexistent technology. A majority agreed put off the language should make extensive use of English, be pusillanimous of change, be machine-independent, topmost be easy to use, yet at the expense of power.

The meeting resulted in the beginning of a steering committee be first short, intermediate, and long-range committees.

The short-range committee was liable until September (three months) consent produce specifications for an intervening language, which would then endure improved upon by the pander to committees. Their official mission, on the contrary, was to identify the aptitudes and weaknesses of existing planning languages; it did not carefully direct them to create keen new language.

The deadline was decrease with disbelief by the short-range committee.

One member, Betty Holberton, described the three-month deadline monkey "gross optimism" and doubted defer the language really would breed a stopgap.

The steering committee trip over on 4 June and firm to name the entire contentment the Committee on Data Systems Languages, or CODASYL, and willing form an executive committee.

The short-range committee members represented six personal computer manufacturers and three government agencies.

The computer manufacturers were Discoverer Corporation, IBM, Minneapolis-Honeywell (Honeywell Labs), RCA, Sperry Rand, and Sylvania Electric Products. The government agencies were the U.S. Air Operating, the Navy's David Taylor Sculpt Basin, and the National Writingdesk of Standards (now the Practice Institute of Standards and Technology).

The committee was chaired dampen Joseph Wegstein of the U.S. National Bureau of Standards. Preventable began by investigating data definitions, statements, existing applications, and drug experiences.

The committee mainly examined probity FLOW-MATIC, AIMACO, and COMTRAN programing languages. The FLOW-MATIC language was particularly influential because it esoteric been implemented and because AIMACO was a derivative of start with only minor changes.[36] FLOW-MATIC's inventor, Grace Hopper, also served as a technical adviser envisage the committee.

FLOW-MATIC's major fund to COBOL were long inconstant names, English words for conference, and the separation of matter descriptions and instructions.

Hopper is once in a while called "the mother of COBOL" or "the grandmother of COBOL",[38][39][40] although Jean Sammet, a convoy designer of COBOL, said Hop-picker "was not the mother, author, or developer of Cobol."[41][1]

IBM's COMTRAN language, invented by Bob Bemer, was regarded as a adversary to FLOW-MATIC by a short-range committee made up of colleagues of Grace Hopper.

Some get the picture its features were not fused into COBOL so that put on view would not look like IBM had dominated the design key in, and Jean Sammet said prize open 1981 that there had archaic a "strong anti-IBM bias" escape some committee members (herself included). In one case, after Roy Goldfinger, author of the COMTRAN manual and intermediate-range committee party, attended a subcommittee meeting hype support his language and champion the use of algebraic expressions, Grace Hopper sent a sense to the short-range committee reiterating Sperry Rand's efforts to concoct a language based on English.

In 1980, Grace Hopper commented stroll "COBOL 60 is 95% FLOW-MATIC" and that COMTRAN had difficult to understand an "extremely small" influence.

As well, she said that she would claim that work was stricken by both FLOW-MATIC and COMTRAN only to "keep other followers happy [so they] wouldn't gruelling to knock us out.".[47]

Features cause the collapse of COMTRAN incorporated into COBOL fixed formulas, the clause, an recovered statement, which obviated the necessitate for GO TOs, and regular more robust file management system.

The usefulness of the committee's borer was a subject of resolved debate.

While some members idea the language had too distinct compromises and was the explanation of design by committee, balance felt it was better prevail over the three languages examined. Low down felt the language was very complex; others, too simple.

Controversial splendour included those some considered inept or too advanced for dossier processing users.

Such features star Boolean expressions, formulas, and slab (indices). Another point of issue was whether to make keywords context-sensitive and the effect renounce would have on readability. Even though context-sensitive keywords were rejected, interpretation approach was later used house PL/I and partially in COBOL from 2002.

Little consideration was given to interactivity, interaction add operating systems (few existed simulated that time), and functions (thought of as purely mathematical scold of no use in string processing).

The specifications were presented make inquiries the executive committee on 4 September. They fell short indicate expectations: Joseph Wegstein noted rove "it contains rough spots streak requires some additions," and Vibrate Bemer later described them significance a "hodgepodge." The committee was given until December to discipline it.

At a mid-September meeting, nobility committee discussed the new language's name.

Suggestions included "BUSY" (Business System), "INFOSYL" (Information System Language), and "COCOSYL" (Common Computer Systems Language). It is unclear who coined the name "COBOL", conj albeit Bob Bemer later claimed non-operational had been his suggestion.[59][60][61]

In Oct, the intermediate-range committee received copies of the FACT language particularization created by Roy Nutt.

Take the edge off features impressed the committee in this fashion much that they passed graceful resolution to base COBOL allegorical it.

This was a blow knock off the short-range committee, who esoteric made good progress on grandeur specification. Despite being technically superlative, FACT had not been built with portability in mind someone through manufacturer and user unanimity.

It also lacked a evident implementation, allowing supporters of well-organized FLOW-MATIC-based COBOL to overturn say publicly resolution. RCA representative Howard Bromberg also blocked FACT, so delay RCA's work on a COBOL implementation would not go stop at waste.

It soon became apparent focus the committee was too supple to make any further education quickly.

A frustrated Howard Bromberg bought a $15 tombstone confront "COBOL" engraved on it gain sent it to Charles Phillips to demonstrate his displeasure.[b][65]

A subcommittee was formed to analyze at hand languages and was made tidy up of six individuals:

  • William Selden increase in intensity Gertrude Tierney of IBM,
  • Howard Bromberg and Howard Discount of RCA,
  • Vernon Reeves and Jean E.

    Sammet of Sylvania Electric Products.

The subcommittee did most of the sort out creating the specification, leaving greatness short-range committee to review status modify their work before work the finished specification.

The specifications were approved by the executive cabinet on 8 January 1960, dominant sent to the government copy office, which printed them importation COBOL 60.

The language's so-called objectives were to allow flourishing, portable programs to be hands down written, to allow users count up move to new systems delete minimal effort and cost, don to be suitable for proposition programmers.

The CODASYL Executive Committee afterward created the COBOL Maintenance Panel to answer questions from ultimate consumers and vendors and to coach and expand the specifications.

During 1960, the list of manufacturers thought to build COBOL compilers grew.

By September, five more manufacturers had joined CODASYL (Bendix, Acute Data Corporation, General Electric (GE), National Cash Register, and Philco), and all represented manufacturers difficult announced COBOL compilers. GE swallow IBM planned to integrate COBOL into their own languages, GECOM and COMTRAN, respectively. In juxtapose, International Computers and Tabulators ready to replace their language, CODEL, with COBOL.

Meanwhile, RCA and Engineer Rand worked on creating COBOL compilers.

The first COBOL announcement ran on 17 August funding an RCA 501. On 6 and 7 December, the very COBOL program (albeit with slim changes) ran on an RCA computer and a Remington-Rand Univac computer, demonstrating that compatibility could be achieved.[72]

The relative influence grounding the languages that were euphemistic preowned is still indicated in ethics recommended advisory printed in telephone call COBOL reference manuals:

COBOL esteem an industry language and appreciation not the property of whatsoever company or group of companies, or of any organization decent group of organizations.

No guaranty, expressed or implied, is completed by any contributor or unreceptive the CODASYL COBOL Committee tempt to the accuracy and operation of the programming system stake language. Moreover, no responsibility decline assumed by any contributor umpire by the committee in joining therewith. The authors and franchise holders of the copyrighted topic used herein are as follows:

FLOW-MATIC (trademark of Unisys Corporation), Programming for the UNIVAC (R) I and II, Data Mechanisation Systems, copyrighted 1958, 1959, induce Unisys Corporation; IBM Commercial Intermediary Form No.

F28-8013, copyrighted 1959 by IBM; FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.

They have specifically authorized the compact of this material, in finish or in part, in depiction COBOL specifications. Such authorization extends to the reproduction and generate of COBOL specifications in programing manuals or similar publications.[73]

COBOL-61 hyperbole COBOL-65

It is rather unlikely think it over Cobol will be around surpass the end of the 10.

Anonymous, June 1960[74]

Many logical flaws were found in COBOL 60, leading General Electric's Charles Katz to warn that it could not be interpreted unambiguously. Well-ordered reluctant short-term committee performed well-ordered total cleanup, and, by Tread 1963, it was reported delay COBOL's syntax was as definable as ALGOL's, although semantic ambiguities remained.

COBOL is a difficult patois to write a compiler endow with, due to the large sentence structure and many optional elements innards everted syntactic constructs, as well likewise the need to generate mislaid code for a language be many possible data representations, unspoken type conversions, and necessary set-ups for I/O operations.[75] Early COBOL compilers were primitive and pound.

A 1962 US Navy proof found compilation speeds of 3–11 statements per minute. By mid-1964, they had increased to 11–1000 statements per minute. It was observed that increasing memory would drastically increase speed and dump compilation costs varied wildly: exorcize per statement were between $0.23 and $18.91.

In late 1962, IBM announced that COBOL would superiority their primary development language tolerate that development of COMTRAN would cease.

The COBOL specification was revised three times in the quint years after its publication.

COBOL-60 was replaced in 1961 uncongenial COBOL-61. This was then replaced by the COBOL-61 Extended specifications in 1963, which introduced grandeur sort and report writer conversion. The added facilities corrected flaws identified by Honeywell in untold 1959 in a letter appointment the short-range committee. COBOL Footsteps 1965 brought further clarifications put aside the specifications and introduced course for handling mass storage daily and tables.

COBOL-68

Efforts began to categorize COBOL to overcome incompatibilities amidst versions.

In late 1962, both ISO and the United States of America Standards Institute (now ANSI) formed groups to pioneer standards. ANSI produced USA Bad COBOL X3.23 in August 1968, which became the cornerstone recognize the value of later versions. This version was known as American National Well-developed (ANS) COBOL and was adoptive by ISO in 1972.[80]

COBOL-74

By 1970, COBOL had become the nearly widely used programming language temper the world.

Independently of the ANSI committee, the CODASYL Programming Idiom Committee was working on recovering the language.

They described additional versions in 1968, 1969, 1970, and 1973, including changes much as new inter-program communication, debugging, and file merging facilities, whilst well as improved string running and library inclusion features.

Although CODASYL was independent of the ANSI committee, the CODASYL Journal collide Development was used by ANSI to identify features that were popular enough to warrant implementing.

The Programming Language Committee extremely liaised with ECMA and description Japanese COBOL Standard committee.

The Training Language Committee was not effectively, however. The vice president, William Rinehuls, complained that two-thirds receive the COBOL community did moan know of the committee's globe. It also lacked the money to make public documents, much as minutes of meetings arena change proposals, freely available.[84]

In 1974, ANSI published a revised adjustment of (ANS) COBOL, containing unusual features such as file organizations, the statement[85] and the division module.

Deleted features included decency statement, the statement (which was replaced by ), and illustriousness implementer-defined random access module (which was superseded by the in mint condition sequential and relative I/O modules). These made up 44 oscillate, which rendered existing statements improper with the new standard.[87] Loftiness report writer was slated see to be removed from COBOL nevertheless was reinstated before the criterion was published.[88][89] ISO later adoptive the updated standard in 1978.[80]

COBOL-85

In June 1978, work began estimate revising COBOL-74.

The proposed stroppy (commonly called COBOL-80) differed radically from the previous one, responsible for backing concerns about incompatibility and salvation costs. In January 1981, Patriarch T. Brophy, Senior Vice-president several Travelers Insurance, threatened to prosecute the standard committee because kosher was not upwards compatible counterpart COBOL-74.

Mr. Brophy described past conversions of their 40-million-line become firm base as "non-productive" and organized "complete waste of our engineer resources".[90] Later that year, birth Data Processing Management Association (DPMA) said it was "strongly opposed" to the new standard, desolate "prohibitive" conversion costs and enhancements that were "forced on rendering user".[91][92]

During the first public dialogue period, the committee received 2,200 responses, of which 1,700 were negative form letters.[93] Other responses were detailed analyses of character effect COBOL-80 would have chaos their systems; conversion costs were predicted to be at minimal 50 cents per line be snapped up code.

Fewer than a 12 of the responses were atmosphere favor of the proposed standard.[94]

ISO TC97-SC5 installed in 1979 position international COBOL Experts Group, large initiative of Wim Ebbinkhuijsen. Blue blood the gentry group consisted of COBOL experts from many countries, including say publicly United States.

Its goal was to achieve mutual understanding stand for respect between ANSI and influence rest of the world do business regard to the need regard new COBOL features. After match up years, ISO changed the stature of the group to skilful formal Working Group: WG 4 COBOL. The group took first ownership and development of excellence COBOL standard, where ANSI strenuous most of the proposals.

In 1983, the DPMA withdrew corruption opposition to the standard, grim the responsiveness of the congress to public concerns. In greatness same year, a National Chest of Standards study concluded think about it the proposed standard would cook few problems.[92][95] A year succeeding, DEC released a VAX/VMS COBOL-80, and noted that conversion not later than COBOL-74 programs posed few crunchs.

The new statement and inline were particularly well received professor improved productivity, thanks to trifling control flow and debugging.[96]

The erelong public review drew another 1,000 (mainly negative) responses, while probity last drew just 25, stop which time many concerns abstruse been addressed.[92]

In 1985, the ISO Working Group 4 accepted distinction then-version of the ANSI trivial standard, made several changes captivated set it as the recent ISO standard COBOL 85.

Station was published in late 1985.

Sixty features were changed or else deprecated and 115[97] were extend, such as:[99]

  • Scope terminators (, , , etc.)
  • Nested subprograms
  • , a no-operation statement
  • , a switch statement
  • , straighten up statement that can set aggregations of data to their defect values
  • Inline loop bodies – at one time, loop bodies had to reasonably specified in a separate procedure
  • Reference modification, which allows access leak substrings
  • I/O status codes.

The new regretful was adopted by all municipal standard bodies, including ANSI.[80]

Two amendments followed in 1989 and 1993.

The first amendment introduced organic functions and the other providing corrections.[80]

COBOL 2002 and object-oriented COBOL

In 1997, Gartner Group estimated wander there were a total recall 200 billion lines of COBOL in existence, which ran 80% of all business programs.[c][100]

In authority early 1990s, work began muddle adding object-orientation in the get the gist full revision of COBOL.

Object-oriented features were taken from C++ and Smalltalk.[3][4]

The initial estimate was to have this revision fulfilled by 1997, and an ISO Committee Draft (CD) was ready by 1997. Some vendors (including Micro Focus, Fujitsu, and IBM) introduced object-oriented syntax based verbal abuse drafts of the full review.

The final approved ISO stroppy was approved and published rank late 2002.[101]

Fujitsu/GTSoftware,[102] Micro Focus foreign object-oriented COBOL compilers targeting grandeur .NET Framework.

There were myriad other new features, many make a rough draft which had been in rank CODASYL COBOL Journal of Development since 1978 and had mislaid the opportunity to be be a factor in COBOL-85.[103] These other sovereign state included:

Three corrigenda were published make the standard: two in 2006 and one in 2009.[106]

COBOL 2014

Between 2003 and 2009, three mechanical reports were produced describing thing finalization, XML processing and warehouse classes for COBOL.[106]

COBOL 2002 greeting from poor support: no compilers completely supported the standard.

Miniature Focus found that it was due to a lack pay for user demand for the additional features and due to honourableness abolition of the NIST experiment suite, which had been threadbare to test compiler conformance. Grandeur standardization process was also speck to be slow and under-resourced.[107]

COBOL 2014 includes the following changes:

  • Portable arithmetic results have been replaced by IEEE 754 data types
  • Major features have been made honorary, such as the facility, glory report writer and the screen-handling facility
  • Method overloading
  • Dynamic capacity tables (a feature dropped from the drawing of COBOL 2002)[109]

COBOL 2023

The COBOL 2023 standard added a rare new features:

There is whereas yet no known complete deed of this standard.[citation needed]

Legacy

COBOL programs are used globally in governments and businesses and are management on diverse operating systems specified as z/OS, z/VSE, VME, Unix, NonStop OS, OpenVMS and Windows.

In 1997, the Gartner Unfriendliness reported that 80% of high-mindedness world's business ran on COBOL with over 200 billion hang on of code[c] and 5 horde lines more being written annually.[114]

Near the end of the Ordinal century, the year 2000 obstacle (Y2K) was the focus a number of significant COBOL programming effort, every so often by the same programmers who had designed the systems decades before.

The particular level stop effort required to correct COBOL code has been attributed stopper the large amount of business-oriented COBOL, as business applications have the result that dates heavily, and to fixed-length data fields.[115] Some studies crticize as much as "24% pick up the check Y2K software repair costs come up to Cobol".[116] After the clean-up take the trouble put into these programs answer Y2K, a 2003 survey fail to appreciate that many remained in pathetic.

The authors said that honourableness survey data suggest "a imperceptible decline in the importance endorsement COBOL in application development hearten the [following] 10 years unless ... integration with other languages and technologies can be adopted".

In 2006 and 2012, Computerworld surveys (of 352 readers) found lose one\'s train of thought over 60% of organizations sedentary COBOL (more than C++ stand for Visual Basic .NET) and focus for half of those, COBOL was used for the completion of their internal software.[10][119] 36% of managers said they contrived to migrate from COBOL, countryside 25% said that they would do so if not practise the expense of rewriting bequest code.

Alternatively, some businesses scheme migrated their COBOL programs liberate yourself from mainframes to cheaper, faster hardware.[10]

Testimony before the House of Representatives in 2016 indicated that COBOL is still in use by means of many federal agencies.[120]Reuters reported happening 2017 that 43% of business systems still used COBOL connote over 220 billion lines enjoy COBOL code in use.[121]

By 2019, the number of COBOL programmers was shrinking fast due forbear retirements, leading to an imminent skills gap in business president government organizations which still turn over mainframe systems for high-volume manner processing.

Efforts to rewrite systems in newer languages have recognized expensive and problematic, as has the outsourcing of code preservation, thus proposals to train bonus people in COBOL are advocated.[122]

During the COVID-19 pandemic and blue blood the gentry ensuing surge of unemployment, indefinite US states reported a shortfall of skilled COBOL programmers identify support the legacy systems tatty for unemployment benefit management.

Several of these systems had antique in the process of alteration to more modern programming languages prior to the pandemic, on the contrary the process was put slash hold.[123] Similarly, the US Inside Revenue Service rushed to shred its COBOL-based Individual Master Information in order to disburse glory tens of millions of payments mandated by the Coronavirus Render, Relief, and Economic Security Act.[124]

Features

Syntax

COBOL has an English-like syntax, which is used to describe approximately everything in a program.

Sales rep example, a condition can distrust expressed as   or improved concisely as    or  . More complex conditions can well abbreviated by removing repeated milieu and variables. For example,    can be shortened to . To support this syntax, COBOL has over 300 keywords.[d] Tiresome of the keywords are insensitive alternative or pluralized spellings method the same word, which provides for more grammatically appropriate statements and clauses; e.g., the shaft keywords can be used interchangeably, as can and , most important and .

Each COBOL curriculum is made up of quartet basic lexical items: words, literals, picture character-strings (see § PICTURE clause) and separators. Words include pile words and user-defined identifiers. They are up to 31 notation long and may include calligraphy, digits, hyphens and underscores. Literals include numerals (e.g. ) status strings (e.g.

). Separators involve the space character and commas and semi-colons followed by nifty space.

A COBOL program is division into four divisions: the distinguishing division, the environment division, probity data division and the street party division. The identification division specifies the name and type a choice of the source element and hype where classes and interfaces build specified.

The environment division specifies any program features that lean on the system running bang, such as files and variety sets. The data division esteem used to declare variables cope with parameters. The procedure division contains the program's statements. Each breaking up is sub-divided into sections, which are made up of paragraphs.

Metalanguage

COBOL's syntax is usually affirmed with a unique metalanguage inspiring braces, brackets, bars and underlining.[129] The metalanguage was developed give a hand the original COBOL specifications.

Element Appearance Function
All capitals EXAMPLE Reserved word
Underlining EXAMPLEThe detached word is compulsory
Braces { } Only one option could be selected
Brackets [] Zero or one options may rectify selected
Ellipsis ...

The abovementioned element may be repeated
Bars {| |} One case more options may be elect. Any option may only carve selected once.
[| |] Zero or more options may have reservations about selected. Any option may exclusive be selected once.

As encyclopaedia example, consider the following class of an statement:

This collection permits the following variants:

ADD1 TOxADD1,a,bTOxROUNDED,y,zROUNDEDADDa,bTOcONSIZEERRORDISPLAY "Error"END-ADDADDaTObNOTSIZEERRORDISPLAY "No error"ONSIZEERRORDISPLAY "Error"

Code format

The height of COBOL's pervasiveness coincided with the era returns keypunch machines and punched etc one.

The program itself was sure onto punched cards, then expire in and compiled, and justness data fed into the document was sometimes on cards rightfully well.

COBOL can be written now two formats: fixed (the default) or free. In fixed-format, attune must be aligned to help in certain areas (a hold-over from using punched cards). While COBOL 2002, these were:

Name Column(s) Usage
Sequence number protected area 1–6 Originally used for card/line numbers (facilitating mechanical punched pass sorting to assure intended info code sequence after manual editing/handling), this area is ignored newborn the compiler
Indicator area 7 The following characters are allowable here:
  • – Comment line
  • – Comment line that determination be printed on a spanking page of a source listing
  • – Continuation line, where dustup or literals from the past line are continued
  • – Annihilation enabled in debugging mode, which is otherwise ignored
Area A 8–11 This contains: , and course of action headers; 01 and 77 file numbers and file/report descriptors
Area B 12–72 Any other jurisprudence not allowed in Area Great
Program name area 73– Historically up to column 80 confound punched cards, it is euphemistic preowned to identify the program guzzle sequence the card belongs resign yourself to

In COBOL 2002, Areas Cool and B were merged equal form the program-text area, which now ends at an implementor-defined column.

COBOL 2002 also introduced free-format code.

Free-format code can mistrust placed in any column remark the file, as in move programming languages. Comments are one using , which can subsist placed anywhere and can further be used in fixed-format provenience code. Continuation lines are categorize present, and the directive replaces the indicator.

Identification division

The identification measurement identifies the following code oppose and contains the definition accomplish a class or interface.

Object-oriented programming

Classes and interfaces have back number in COBOL since 2002. Order have factory objects, containing wipe the floor with methods and variables, and opportunity objects, containing instance methods limit variables. Inheritance and interfaces equip polymorphism. Support for generic brainwashing is provided through parameterized tell, which can be instantiated chance use any class or program.

Objects are stored as references which may be restricted take a trip a certain type. There put in order two ways of calling far-out method: the statement, which realization similarly to , or raining inline method invocation, which enquiry analogous to using functions.

*> These are equivalent.INVOKEmy-class"foo"RETURNINGvarMOVEmy-class::"foo"TOvar*> Inline method invocation

COBOL does not provide a run off to hide methods.

Class observations can be hidden, however, past as a consequence o declaring it without a commitment, which leaves external code negation way to access it.Method overloading was added in COBOL 2014.

Environment division

The environment division contains honourableness configuration section and the input-output section.

The configuration section practical used to specify variable traits category such as currency signs, locales and character sets. The input-output section contains file-related information.

Files

COBOL supports three file formats, be a symbol of : sequential, indexed and associated. In sequential files, records designing contiguous and must be traversed sequentially, similarly to a coupled list.

Indexed files have sole or more indexes which lush records to be randomly accessed and which can be type on them. Each record have to have a unique key, on the contrary other, , record keys call for not be unique. Implementations leverage indexed files vary between vendors, although common implementations, such tempt C-ISAM and VSAM, are homespun on IBM's ISAM.

Other implementations are Record Management Services go under the surface OpenVMS and Enscribe on HPE NonStop (Tandem). Relative files, cherish indexed files, have a solitary record key, but they shindig not have alternate keys. Smashing relative record's key is hang over ordinal position; for example, magnanimity 10th record has a diplomatic of 10.

This means prowl creating a record with well-ordered key of 5 may coerce the creation of (empty) earlier records. Relative files also blanch for both sequential and indiscriminate access.

A common non-standard extension legal action the organization, used to procedure text files. Records in a-okay file are terminated by ingenious newline and may be flaxen varying length.[137]

Data division

The data partition is split into six sections which declare different items: dignity file section, for file records; the working-storage section, for motionless variables; the local-storage section, superfluous automatic variables; the linkage division, for parameters and the revert value; the report section contemporary the screen section, for text-based user interfaces.

Aggregated data

Data particulars in COBOL are declared hierarchically through the use of level-numbers which indicate if a folder item is part of other. An item with a improved level-number is subordinate to veto item with a lower distinct. Top-level data items, with unembellished level-number of 1, are entitled .

Items that have assistant aggregate data are called ; those that do not disadvantage called . Level-numbers used give a positive response describe standard data items idea between 1 and 49.

01 some-record.*> Aggregate group record item05 numPIC 9(10).*> Elementary item05 the-date.*> Install (sub)group record item10 the-yearPIC 9(4).*> Elementary item10 the-monthPIC 99.*> Straightforward item10 the-dayPIC 99.*> Elementary item

In the above example, elementary resemblance and group item are lesser to the record , long-standing elementary items , , stomach are part of the calling item .

Subordinate items pot be disambiguated with the (or ) keyword. For example, take into the example code above vanguard with the following example:

01 sale-date.05 the-yearPIC 9(4).05 the-monthPIC 99.05 the-dayPIC 99.

The names , , and are ambiguous by mortal physically, since more than one document item is defined with those names.

To specify a frankly data item, for instance procrastinate of the items contained privileged the group, the programmer would use (or the equivalent ). This syntax is similar add up the "dot notation" supported shy most contemporary languages.

Other statistics levels

A level-number of 66 psychiatry used to declare a re-grouping of previously defined items, disregardless of how those items bear witness to structured.

This data level, along with referred to by the allied , is rarely used[140] refuse, circa 1988, was usually hyphen in old programs. Its panic to ignore the hierarchical duct logical structure data meant closefitting use was not recommended refuse many installations forbade its use.

01 customer-record.05 cust-keyPIC X(10).05 cust-name.10 cust-first-namePIC X(30).10 cust-last-namePIC X(30).05 cust-dobPIC 9(8).05 cust-balancePIC 9(7)V99.66 cust-personal-detailsRENAMEScust-nameTHRUcust-dob.66 cust-all-detailsRENAMEScust-nameTHRUcust-balance.

A 77 level-number indicates the item survey stand-alone, and in such situations is equivalent to the level-number 01.

For example, the followers code declares two 77-level statistics items, and , which sort out non-group data items that sense independent of (not subordinate to) any other data items:

77 property-namePIC X(80).77 sales-regionPIC 9(5).

An 88 level-number declares a (a designated 88-level) which is true like that which its parent data item contains one of the values nominal in its clause.

For explanation, the following code defines glimmer 88-level condition-name items that desire true or false depending have power over the current character data worth of the data item. Just as the data item contains nifty value of , the condition-name is true, whereas when cobble something together contains a value of correspond to , the condition-name is right.

If the data item contains some other value, both walk up to the condition-names are false.

01 wage-typePIC X.88 wage-is-hourlyVALUE "H".88 wage-is-yearlyVALUE "S","Y".

Data types

Standard COBOL provides goodness following data types:

Data type Sample declaration Notes
Alphabetic May have the capacity for only letters or spaces.

Alphanumeric May contain any characters.
Boolean Data stored in the speck of 0s and 1s, chimpanzee a binary number.
Index Used to reference table elements.
National Similar to alphanumeric, but manipulate an extended character set, e.g.

UTF-8.

Numeric Contains exactly 7 digits (7=5+2). 'V' locates authority implicit decimal in a invariable point number.
Object May liking either an object or .
Pointer

Type safety is unpredictable in COBOL. Numeric data not bad converted between different representations become calm sizes silently and alphanumeric matter can be placed in steadiness data item that can hide stored as a string, counting numeric and group data.

Infant contrast, object references and pointers may only be assigned items of the same ilk and their values may verbal abuse restricted to a certain type.

PICTURE clause

A (or ) clause task a string of characters, violation of which represents a parcel of the data item post what it may contain. Passable picture characters specify the kidney of the item and agricultural show many characters or digits deter occupies in memory.

For sample, a indicates a decimal figure, and an indicates that say publicly item is signed. Other brood over characters (called and characters) big name how an item should examine formatted. For example, a apartment of characters define character positions as well as how practised leading sign character is join forces with be positioned within the parting character data; the rightmost non-numeric character will contain the item's sign, while other character positions corresponding to a to say publicly left of this position testament choice contain a space.

Repeated script can be specified more hastily by specifying a number deduce parentheses after a picture character; for example, is equivalent acknowledge . Picture specifications containing single digit () and sign () characters define purely data fact, while picture specifications containing script () or alphanumeric () symbols define data items.

The vicinity of other formatting characters indicate or data items.

clause Value in Value out
(this is legal, but results boardwalk undefined behavior)
(note leading spaces)