cobol this article is about the compiled programming language for other uses see cobol disambiguation cobol kobl bl an acronym for common businessoriented language is a compiled englishlike computer programming language designed for business use it is imperative procedural and since 2002 objectoriented cobol is primarily used in business finance and administrative systems for companies and governments cobol is still widely used in legacy applications deployed on mainframe computers such as largescale batch and transaction processing jobs but due to its declining popularity and the retirement of experienced cobol programmers programs are being migrated to new platforms rewritten in modern languages or replaced with software packages cobol was designed in 1959 by codasyl and was partly based on previous programming language design work by grace hopper commonly referred to as the grandmother of cobol cobol statements have an englishlike syntax which was designed to be selfdocumenting and highly readable however it is verbose and uses over 300 reserved words in contrast with modern succinct syntax like y x cobol has a more englishlike syntax in this case move x to y cobol code is split into four divisions identification environment data and procedure containing a rigid hierarchy of sections paragraphs and sentences lacking a large standard library the standard specifies 43 statements 87 functions and just one class academic computer scientists were generally uninterested in business applications when cobol was created and were not involved in its design it was effectively designed from the ground up as a computer language for business with an emphasis on inputs and outputs whose only data types were numbers and strings of text cobol has been criticized throughout its life however for its verbosity design process and poor support for structured programming these weaknesses result in monolithic and though intended to be englishlike not easily comprehensible and verbose programs history and specification background in the late 1950s computer users and manufacturers were becoming concerned about the rising cost of programming a 1959 survey had found that in any data processing installation the programming cost us800000 on average and that translating programs to run on new hardware would cost 600000 at a time when new programming languages were proliferating at an everincreasing rate the same survey suggested that if a common businessoriented language were used conversion would be far cheaper and faster grace hopper the inventor of flowmatic a predecessor to cobol in april 1959 mary k hawes a computer scientist at burroughs corporation called a meeting of representatives from academia computer users and manufacturers at the university of pennsylvania to organize a formal meeting on common business languages the group asked the department of defense dod to sponsor an effort to create a common business language the delegation impressed charles a phillips director of the data system research staff at the dod who thought that they thoroughly understood the dods problems the dod operated 225 computers had a further 175 on order and had spent over 200 million on implementing programs to run on them portable programs would save time reduce costs and ease modernization phillips agreed to sponsor the meeting and tasked the delegation with drafting the agenda cobol 60 on may 28 and 29 of 1959 exactly one year after the zrich algol 58 meeting a meeting was held at the pentagon to discuss the creation of a common programming language for business it was attended by 41 people and was chaired by phillips representatives enthusiastically described a language that could work in a wide variety of environments from banking and insurance to utilities and inventory control they agreed unanimously that more people should be able to program and that the new language should not be restricted by the limitations of contemporary technology a majority agreed that the language should make maximal use of english be capable of change be machineindependent and be easy to use even at the expense of power the meeting resulted in the creation of a steering committee and short intermediate and longrange committees the shortrange committee was given to september three months to produce specifications for an interim language which would then be improved upon by the other committees the deadline was met with disbelief by the shortrange committee one member betty holberton described the threemonth deadline as gross optimism and doubted that the language really would be a stopgap the steering committee met on june 4 and agreed to name the entire activity as the committee on data systems languages or codasyl and to form an executive committee the shortrange committee was made up of members representing six computer manufacturers and three government agencies the six computer manufacturers were burroughs corporation ibm minneapolishoneywell honeywell labs rca sperry rand and sylvania electric products the three government agencies were the us air force the navys david taylor model basin and the national bureau of standards now the national institute of standards and technology the committee mainly examined the flowmatic aimaco and comtran programming languages the flowmatic language was particularly influential because it had been implemented and because aimaco was a derivative of it with only minor changes flowmatics inventor grace hopper also served as a technical adviser to the committee ibms comtran language invented by bob bemer was regarded as a competitor to flowmatic some of its features were not incorporated into cobol so that it would not look like ibm had dominated the design process in one case after roy goldfinger author of the comtran manual and intermediaterange committee member attended a subcommittee meeting to support his language and encourage the use of algebraic expressions grace hopper sent a memo to the shortrange committee reiterating sperry rands efforts to create a language based on english in 1980 grace hopper commented that cobol 60 is 95 flowmatic and that comtran had had an extremely small influence furthermore she said that she would claim that work was influenced by both flowmatic and comtran only to keep other people happy features from comtran incorporated into cobol included formulas the usefulness of the committees work was subject of great debate while some members thought the language had too many compromises and was the result of design by committee others felt it was better than the three languages examined some felt the language was too complex others too simple controversial features included those some considered useless or too advanced for data processing users such features included boolean expressions formulas and table subscripts indices the specifications were presented to the executive committee on september 4 they fell short of expectations joseph wegstein noted that it contains rough spots and requires some additions and bob bemer later described them as a hodgepodge the subcommittee was given until december to improve it at a midseptember meeting the committee discussed the new languages name suggestions included busy business system infosyl information system language and cocosyl common computer systems language in october the intermediaterange committee received copies of the fact language specification created by roy nutt its features impressed the committee so much that they passed a resolution to base cobol on it this was a blow to the shortrange committee who had made good progress on the specification despite being technically superior fact had not been created with portability in mind or through manufacturer and user consensus it also lacked a demonstrable implementation mwparseroutput quoteboxbackgroundcolorf9f9f9border1px solid aaaboxsizingborderboxpadding10pxfontsize88mwparseroutput quoteboxfloatleftmargin05em 14em 08em 0mwparseroutput quoteboxfloatrightmargin05em 0 08em 14emmwparseroutput quoteboxcenteredmargin05em auto 08em automwparseroutput quoteboxfloatleft pmwparseroutput quoteboxfloatright pfontstyleinheritmwparseroutput quoteboxtitlebackgroundcolorf9f9f9textaligncenterfontsizelargerfontweightboldmwparseroutput quoteboxquotequotedbeforefontfamilytimes new romanseriffontweightboldfontsizelargecolorgraycontent verticalalign45lineheight0mwparseroutput quoteboxquotequotedafterfontfamilytimes new romanseriffontweightboldfontsizelargecolorgraycontent lineheight0mwparseroutput quotebox leftalignedtextalignleftmwparseroutput quotebox rightalignedtextalignrightmwparseroutput quotebox centeralignedtextaligncentermwparseroutput quotebox citedisplayblockfontstylenormalmedia screen and maxwidth360pxmwparseroutput quoteboxminwidth100margin0 0 08emimportantfloatnoneimportant and what name do you want inscribed i said ill write it for you i wrote the name down cobol what kind of name is that well its a polish name we shortened it and got rid of a lot of unnecessary notation howard bromberg on how he bought the cobol tombstone it soon became apparent that the committee was too large for any further progress to be made quickly a frustrated howard bromberg bought a 15 tombstone with cobol engraved on it and sent it to charles phillips to demonstrate his displeasure a subcommittee was formed to analyze existing languages and was made up of six individuals william selden and 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 work creating the specification leaving the shortrange committee to review and modify their work before producing the finished specification the cover of the cobol 60 report the specifications were approved by the executive committee on january 3 1960 and sent to the government printing office which printed these as cobol 60 the languages stated objectives were to allow efficient portable programs to be easily written to allow users to move to new systems with minimal effort and cost and to be suitable for inexperienced programmers the codasyl executive committee later created the cobol maintenance committee to answer questions from users and vendors and to improve and expand the specifications during 1960 the list of manufacturers planning to build cobol compilers grew by september five more manufacturers had joined codasyl bendix control data corporation general electric ge national cash register and philco and all represented manufacturers had announced cobol compilers ge and ibm planned to integrate cobol into their own languages gecom and comtran respectively in contrast international computers and tabulators planned to replace their language codel with cobol meanwhile rca and sperry rand worked on creating cobol compilers the first cobol program ran on 17 august on an rca 501 on december 6 and 7 the same cobol program albeit with minor changes ran on an rca computer and a remingtonrand univac computer demonstrating that compatibility could be achieved the relative influences of which languages were used continues to this day in the recommended advisory printed in all cobol reference manuals mwparseroutput templatequoteoverflowhiddenmargin1em 0padding0 40pxmwparseroutput templatequote templatequotecitelineheight15emtextalignleftpaddingleft16emmargintop0cobol is an industry language and is not the property of any company or group of companies or of any organization or group of organizations no warranty expressed or implied is made by any contributor or by the codasyl cobol committee as to the accuracy and functioning of the programming system and language moreover no responsibility is assumed by any contributor or by the committee in connection therewith the authors and copyright holders of the copyrighted material used herein are as follows flowmatic trademark of unisys corporation programming for the univac r i and ii data automation systems copyrighted 1958 1959 by unisys corporation ibm commercial translator form no f288013 copyrighted 1959 by ibm fact dsi 27a52602760 copyrighted 1960 by minneapolishoneywell they have specifically authorized the use of this material in whole or in part in the cobol specifications such authorization extends to the reproduction and use of cobol specifications in programming manuals or similar publications cobol61 to cobol65 it is rather unlikely that cobol will be around by the end of the decade anonymous june 1960 many logical flaws were found in cobol 60 leading ges charles katz to warn that it could not be interpreted unambiguously a reluctant shortterm committee enacted a total cleanup and by march 1963 it was reported that cobols syntax was as definable as algols although semantic ambiguities remained early cobol compilers were primitive and slow a 1962 us navy evaluation found compilation speeds of 311 statements per minute by mid1964 they had increased to 111000 statements per minute it was observed that increasing memory would drastically increase speed and that compilation costs varied wildly costs per statement were between 023 and 1891 in late 1962 ibm announced that cobol would be their primary development language and that development of comtran would cease the cobol specification was revised three times in the five years after its publication cobol60 was replaced in 1961 by cobol61 this was then replaced by the cobol61 extended specifications in 1963 which introduced the sort and report writer facilities the added facilities corrected flaws identified by honeywell in late 1959 in a letter to the shortrange committee cobol edition 1965 brought further clarifications to the specifications and introduced facilities for handling mass storage files and tables cobol68 efforts began to standardize cobol to overcome incompatibilities between versions in late 1962 both iso and the united states of america standards institute now ansi formed groups to create standards ansi produced usa standard cobol x323 in august 1968 which became the cornerstone for later versions cobol74 by 1970 cobol had become the most widely used programming language in the world independently of the ansi committee the codasyl programming language committee was working on improving the language they described new versions in 1968 1969 1970 and 1973 including changes such as new interprogram communication debugging and file merging facilities as well as improved stringhandling and library inclusion features although codasyl was independent of the ansi committee the codasyl journal of development was used by ansi to identify features that were popular enough to warrant implementing the programming language committee also liaised with ecma and the japanese cobol standard committee the programming language committee was not wellknown however the vicepresident william rinehuls complained that twothirds of the cobol community did not know of the committees existence it was also poor lacking the funds to make public documents such as minutes of meetings and change proposals freely available in 1974 ansi published a revised version of ans cobol containing new features such as file organizations the delete statement deleted features included the note statement the examine statement which was replaced by inspect and the implementerdefined random access module which was superseded by the new sequential and relative io modules these made up 44 changes which rendered existing statements incompatible with the new standard the report writer was slated to be removed from cobol but was reinstated before the standard was published cobol85 in june 1978 work began on revising cobol74 the proposed standard commonly called cobol80 differed significantly from the previous one causing concerns about incompatibility and conversion costs in january 1981 joseph t brophy senior vicepresident of travelers insurance threatened to sue the standard committee because it was not upwards compatible with cobol74 mr brophy described previous conversions of their 40millionline code base as nonproductive and a complete waste of our programmer resources later that year the data processing management association dpma said it was strongly opposed to the new standard citing prohibitive conversion costs and enhancements that were forced on the user during the first public review period the committee received 2200 responses of which 1700 were negative form letters other responses were detailed analyses of the effect cobol80 would have on their systems conversion costs were predicted to be at least 50 cents per line of code fewer than a dozen of the responses were in favor of the proposed standard in 1983 the dpma withdrew its opposition to the standard citing the responsiveness of the committee to public concerns in the same year a national bureau of standards study concluded that the proposed standard would present few problems the second public review drew another 1000 mainly negative responses while the last drew just 25 by which time many concerns had been addressed in late 1985 ansi published the revised standard sixty features were changed or deprecated and many scope terminators endif endperform endread etc nested subprograms continue a nooperation statement evaluate a switch statement initialize a statement that can set groups of data to their default values inline perform loop bodies previously loop bodies had to be specified in a separate procedure reference modification which allows access to substrings io status codes the standard was adopted by iso the same year before subsequently taking primary ownership and development of the standard cobol 2002 and objectoriented cobol in 1997 gartner group estimated that there were a total of 200 billion lines of cobol in existence which ran 80 of all business programs in the early 1990s work began on adding objectorientation in the next full revision of cobol objectoriented features were taken from c and smalltalk the initial estimate was to have this revision completed by 1997 and an iso committee draft cd was available by 1997 some vendors including micro focus fujitsu and ibm introduced objectoriented syntax based on drafts of the full revision the final approved iso standard was approved and published in late 2002 fujitsugtsoftware micro focus and raincode introduced objectoriented cobol compilers targeting the net framework there were many other new features many of which had been in the codasyl cobol journal of development since 1978 and had missed the opportunity to be included in cobol85 freeform code userdefined functions recursion localebased processing support for extended character sets such as unicode floatingpoint and binary data types until then binary items were truncated based on their declarations base10 specification portable arithmetic results bit and boolean data types pointers and syntax for getting and freeing storage the screen section for textbased user interfaces the validate facility improved interoperability with other programming languages and framework environments such as net and java three corrigenda were published for the standard two in 2006 and one in 2009 cobol 2014 between 2003 and 2009 three technical reports were produced describing object finalization xml processing and collection classes for cobol cobol 2002 suffered from poor support no compilers completely supported the standard micro focus found that it was due to a lack of user demand for the new features and due to the abolition of the nist test suite which had been used to test compiler conformance the standardization process was also found to be slow and underresourced cobol 2014 includes the following changes portable arithmetic results have been replaced by ieee 754 data types major features have been made optional such as the validate facility the report writer and the screenhandling facility method overloading dynamic capacity tables a feature dropped from the draft of cobol 2002 legacy cobol programs are used globally in governments and businesses and are running on diverse operating systems such as zos zvse vme unix openvms and windows in 1997 the gartner group reported that 80 of the worlds business ran on cobol with over 200 billion lines of code and 5 billion lines more being written annually near the end of the 20th century the year 2000 problem y2k was the focus of significant cobol programming effort sometimes by the same programmers who had designed the systems decades before the particular level of effort required to correct cobol code has been attributed the authors said that the survey data suggest a gradual decline in the importance of cobol in application development over the in 2006 and 2012 computerworld surveys found that over 60 of organizations used cobol more than c and visual basic net and that for half of those cobol was used for the majority of their internal software features syntax cobol has an englishlike syntax which is used to describe nearly everything in a program for example a condition can be expressed as x is greater than y or more concisely as x greater y or x y more complex conditions can be abbreviated by removing repeated conditions and variables for example a b and a c or a d can be shortened to a b and c or d as a consequence of this englishlike syntax cobol has over 300 keywords some of the keywords are simple alternative or pluralized spellings of the same word which provides for more englishlike statements and clauses eg the in and of keywords can be used interchangeably as can is and are and value and values each cobol program is made up of four basic lexical items words literals picture characterstrings see picture clause and separators words include reserved words and userdefined identifiers they are up to 31 characters long and may include letters digits hyphens and underscores literals include numerals eg 12 and strings eg hello a cobol program is split into four divisions the identification division the environment division the data division and the procedure division the identification division specifies the name and type of the source element and is where classes and interfaces are specified the environment division specifies any program features that depend on the system running it such as files and character sets the data division is used to declare variables and parameters the procedure division contains the programs statements each division is subdivided into sections which are made up of paragraphs metalanguage cobols syntax is usually described with a unique metalanguage using braces brackets bars and underlining the metalanguage was developed for the original cobol specifications although backusnaur form did exist at the time the committee had not heard of it elements of cobols metalanguage element appearance function all capitals example reserved word underlining example the reserved word is compulsory braces only one option may be selected brackets zero or one options may be selected ellipsis the preceding element may be repeated bars one or more options may be selected any option may only be selected once zero or more options may be selected any option may only be selected once as an example consider the following description of an add statement add identifier1 literal1 to identifier2 rounded on size error imperativestatement1 not on size error imperativestatement2 endadd displaystyle beginarraylunderline textaddbeginbmatrixtextidentifier1textliteral1endbmatrixdots underline texttolefttextidentifier2leftendarray this description permits the following variants add 1 to x add 1 a b to x rounded y z rounded add a b to c on size error display error endadd add a to b not size error display no error on size error display error code format cobol can be written in two formats fixed the default or free in fixedformat code must be aligned to fit in certain areas a holdover from using punched cards until cobol 2002 these were name columns usage sequence number area 16 originally used for cardline numbers this area is ignored by the compiler indicator area 7 the following characters are allowed here comment line comment line that will be printed on a new page of a source listing continuation line where words or literals from the previous line are continued d line enabled in debugging mode which is otherwise ignored area a 811 this contains division section and procedure headers 01 and 77 level numbers and filereport descriptors area b 1272 any other code not allowed in area a program name area 73 historically up to column 80 for punched cards it is used to identify the program or sequence the card belongs to in cobol 2002 areas a and b were merged to form the programtext area which now ends at an implementordefined column cobol 2002 also introduced freeformat code freeformat code can be placed in any column of the file as in newer programming languages comments are specified using which can be placed anywhere and can also be used in fixedformat source code continuation lines are not present and the page directive replaces the indicator identification division the identification division identifies the following code entity and contains the definition of a class or interface objectoriented programming classes and interfaces have been in cobol since 2002 classes have factory objects containing class methods and variables and instance objects containing instance methods and variables these are equivalent invoke myclass foo returning var move myclassfoo to var inline method invocation cobol does not provide a way to hide methods class data can be hidden however by declaring it without a property clause which leaves the user with no way to access it environment division the environment division contains the configuration section and the inputoutput section the configuration section is used to specify variable features such as currency signs locales and character sets the inputoutput section contains filerelated information files cobol supports three file formats or organizations sequential indexed and relative in sequential files records are contiguous and must be traversed sequentially similarly to a linked list indexed files have one or more indexes which allow records to be randomly accessed and which can be sorted on them each record must have a unique key but other alternate record keys need not be unique implementations of indexed files vary between vendors although common implementations such as cisam and vsam are based on ibms isam relative files like indexed files have a unique record key but they do not have alternate keys a relative records key is its ordinal position for example the 10th record has a key of 10 this means that creating a record with a key of 5 may require the creation of empty preceding records relative files also allow for both sequential and random access a common nonstandard extension is the line sequential organization used to process text files records in a file are terminated by a newline and may be of varying length data division the data division is split into six sections which declare different items the file section for file records the workingstorage section for static variables the localstorage section for automatic variables the linkage section for parameters and the return value the report section and the screen section for textbased user interfaces aggregated data data items in cobol are declared hierarchically through the use of levelnumbers which indicate if a data item is part of another an item with a higher levelnumber is subordinate to an item with a lower one toplevel data items with a levelnumber of 1 are called records items that have subordinate aggregate data are called group items those that do not are called elementary items levelnumbers used to describe standard data items are between 1 and 49 01 somerecord aggregate group record item 05 num pic 910 elementary item 05 thedate aggregate subgroup record item 10 theyear pic 94 elementary item 10 themonth pic 99 elementary item 10 theday pic 99 elementary item in the above example elementary item num and group item thedate are subordinate to the record somerecord while elementary items theyear themonth and theday are part of the group item thedate subordinate items can be disambiguated with the in or of keyword for example consider the example code above along with the following example 01 saledate 05 theyear pic 94 05 themonth pic 99 05 theday pic 99 the names theyear themonth and theday are ambiguous by themselves since more than one data item is defined with those names to specify a particular data item for instance one of the items contained within the saledate group the programmer would use theyear in saledate or the equivalent theyear of saledate this syntax is similar to the dot notation supported by most contemporary languages other data levels a levelnumber of 66 is used to declare a regrouping of previously defined items irrespective of how those items are structured this data level also referred to by the associated renames clause is rarely used 01 customerrecord 05 custkey pic x10 05 custname 10 custfirstname pic x30 10 custlastname pic x30 05 custdob pic 98 05 custbalance pic 97v99 66 custpersonaldetails renames custname thru custdob 66 custalldetails renames custname thru custbalance a 77 levelnumber indicates the item is standalone and in such situations is equivalent to the levelnumber 01 for example the following code declares two 77level data items propertyname and salesregion which are nongroup data items that are independent of not subordinate to any other data items 77 propertyname pic x80 77 salesregion pic 95 an 88 levelnumber declares a condition name a socalled 88level which is true when its parent data item contains one of the values specified in its value clause for example the following code defines two 88level conditionname items that are true or false depending on the current character data value of the wagetype data item when the data item contains a value of h the conditionname wageishourly is true whereas when it contains a value of s or y the conditionname wageisyearly is true if the data item contains some other value both of the conditionnames are false 01 wagetype pic x 88 wageishourly value h 88 wageisyearly value s y data types standard cobol provides the following data types data type sample declaration notes alphabetic pic a30 may only contain letters or spaces alphanumeric pic x30 may contain any characters boolean pic 1 usage bit data stored in the form of 0s and 1s as a binary number index usage index used to reference table elements national pic n30 similar to alphanumeric but using an extended character set eg utf8 numeric pic 95v95 may contain only numbers object usage object reference may reference either an object or null pointer usage pointer type safety is variable in cobol numeric data is converted between different representations and sizes silently and alphanumeric data can be placed in any data item that can be stored as a string including numeric and group data picture clause a picture or pic clause is a string of characters each of which represents a portion of the data item and what it may contain some picture characters specify the type of the item and how many characters or digits it occupies in memory for example a 9 indicates a decimal digit and an s indicates that the item is signed other picture characters called insertion and editing characters specify how an item should be formatted for example a series of characters define character positions as well as how a leading sign character is to be positioned within the final character data the rightmost nonnumeric character will contain the items sign while other character positions corresponding to a to the left of this position will contain a space repeated characters can be specified more concisely by specifying a number in parentheses after a picture character for example 97 is equivalent to 9999999 picture specifications containing only digit 9 and sign s characters define purely numeric data items while picture specifications containing alphabetic a or alphanumeric x characters define alphanumeric data items the presence of other formatting characters define edited numeric or edited alphanumeric data items examples picture clause value in value out pic 95 100 00100 hello hello this is legal but results in undefined behavior pic 10 10 note leading spaces pic 999994 31042003 31042003 pic 4999 10050 10050 0 000 pic x3bx3bx3 abcdefghi abc def ghi usage clause the usage clause declares the format data is stored in depending on the data type it can either complement or be used instead of a picture clause while it can be used to declare pointers and object references it is mostly geared towards specifying numeric types these numeric formats are binary where a minimum size is either specified by the picture clause or by a usage clause such as binarylong usage computational where data may be stored in whatever format the implementation provides often equivalent to usage binary usage display the default format where data is stored as a string floatingpoint in either an implementationdependent format or according to ieee 754 usage national where data is stored as a string using an extended character set usage packeddecimal where data is stored in the smallest possible decimal format typically packed binarycoded decimal report writer the report writer is a declarative facility for creating reports the programmer need only specify the report layout and the data required to produce it freeing them from having to write code to handle things like page breaks data formatting and headings and footings reports are associated with report files which are files which may only be written to through report writer statements fd reportout report salesreport each report is defined in the report section of the data division a report is split into report groups which define the reports headings footings and details reports work around hierarchical control breaks control breaks occur when a key variable changes it value for example when creating a report detailing customers orders a control break could occur when the program reaches a different customers orders here is an example report description for a report which gives a salespersons sales and which warns of any invalid records rd salesreport page limits 60 lines first detail 3 controls sellername 01 type page heading 03 col 1 value sales report 03 col 74 value page 03 col 79 pic z9 source pagecounter 01 salesonday type detail line 1 03 col 3 value sales on 03 col 12 pic 99999999 source salesdate 03 col 21 value were 03 col 26 pic 999 source salesamount 01 invalidsales type detail line 1 03 col 3 value invalid record 03 col 19 pic x34 source salesrecord 01 type control heading sellername line 2 03 col 1 value seller 03 col 9 pic x30 source sellername the above report description describes the following layout sales report page 1 seller howard bromberg sales on 10122008 were 100000 sales on 12122008 were 000 sales on 13122008 were 3147 invalid record howard bromberg xxxxyy seller howard discount sales report page 12 sales on 08052014 were 54398 invalid record william selden 12o52014foofoo sales on 30052014 were 000 four statements control the report writer initiate which prepares the report writer for printing generate which prints a report group suppress which suppresses the printing of a report group and terminate which terminates report processing for the above sales report example the procedure division might look like this open input sales output reportout initiate salesreport perform until 1 1 read sales at end exit perform endread validate salesrecord if validrecord generate salesonday else generate invalidsales endif endperform terminate salesreport close sales reportout procedure division procedures the sections and paragraphs in the procedure division collectively called procedures can be used as labels and as simple subroutines unlike in other divisions paragraphs do not need to be in sections execution goes down through the procedures of a program until it is terminated to use procedures as subroutines the perform verb is used this transfers control to the specified range of procedures and returns only upon reaching the end a mine is armed when the screen is invalid unusual control flow can trigger mines which cause control in performed procedures to return at unexpected times to unexpected locations procedures can be reached in three ways they can be called with perform jumped to from a go to or through execution falling through the bottom of an above paragraph combinations of these invoke undefined behavior creating mines specifically mines occur when execution of a range of procedures would cause control flow to go past the last statement of a range of procedures already being performed for example in the code in the adjacent image a mine is tripped at the end of updatescreen when the screen is invalid when the screen is invalid control jumps to the fixscreen section which when done performs updatescreen this recursion triggers undefined behavior as there are now two overlapping ranges of procedures being performed the mine is then triggered upon reaching the end of updatescreen and means control could return to one of two locations the first perform statement the perform statement in fixscreen where it would then fallthrough into updatescreen and return to the first perform statement upon reaching the end statements cobol 2014 has 47 statements also called verbs which can be grouped into the following broad categories control flow io data manipulation and the report writer the report writer statements are covered in the report writer section control flow cobols conditional statements are if and evaluate evaluate is a switchlike statement with the added capability of evaluating multiple values and conditions this can be used to implement decision tables for example the following might be used to control a cnc lathe evaluate true also desiredspeed also currentspeed when lidclosed also minspeed thru maxspeed also less than desiredspeed perform speedupmachine when lidclosed also minspeed thru maxspeed also greater than desiredspeed perform slowdownmachine when lidopen also any also not zero perform emergencystop when other continue endevaluate the perform statement is used to define loops which are executed until a condition is true not while true which is more common in other languages it is also used to call procedures or ranges of procedures see the procedures section for more details call and invoke call subprograms and methods respectively the name of the subprogrammethod is contained in a string which may be a literal or a data item cancel unloads subprograms from memory go to causes the program to jump to a specified procedure the goback statement is a return statement and the stop statement stops the program the exit statement has six different formats it can be used as a return statement a break statement a continue statement an end marker or to leave a procedure exceptions are raised by a raise statement and caught with a handler or declarative defined in the declaratives portion of the procedure division declaratives are sections beginning with a use statement which specify the errors to handle exceptions can be names or objects resume is used in a declarative to jump to the statement after the one that raised the exception or to a procedure outside the declaratives unlike other languages uncaught exceptions may not terminate the program and the program can proceed unaffected io file io is handled by the selfdescribing open close read and write statements along with a further three rewrite which updates a record start which selects subsequent records to access by finding a record with a certain key and unlock which releases a lock on the last record accessed user interaction is done using accept and display data manipulation the following verbs manipulate data initialize which sets data items to their default values move which assigns values to data items set which has 15 formats it can modify indices assign object references and alter table capacities among other functions add subtract multiply divide and compute which handle arithmetic with compute assigning the result of a formula to a variable allocate and free which handle dynamic memory validate which validates and distributes data as specified in an items description in the data division string and unstring which concatenate and split strings respectively inspect which tallies or replaces instances of specified substrings within a string search which searches a table for the first entry satisfying a condition files and tables are sorted using sort and the merge verb merges and sorts files the release verb provides records to sort and return retrieves sorted records in order scope termination some statements such as if and read may themselves contain statements such statements may be terminated in two ways by a period implicit termination which terminates all unterminated statements contained or by a scope terminator which terminates the nearest matching open statement terminator period implicit termination if invalidrecord if nomorerecords next sentence else read recordfile at end set nomorerecords to true scope terminators explicit termination if invalidrecord if nomorerecords continue else read recordfile at end set nomorerecords to true endread endif endif nested statements terminated with a period are a common source of bugs for example examine the following code if x display y display z here the intent is to display y and z if condition x is true however z will be displayed whatever the value of x because the if statement is terminated by an erroneous period after display y another bug is a result of the dangling else problem when two if statements can associate with an else if x if y display a else display b in the above fragment the else associates with the if y statement instead of the if x statement causing a bug prior to the introduction of explicit scope terminators preventing it would require else next sentence to be placed after the inner if selfmodifying code the original 1959 cobol specification supported the infamous alter x to proceed to y statement for which many compilers generated selfmodifying code x and y are procedure labels and the single go to statement in procedure x executed after such an alter statement means go to y instead many compilers still support it but it was deemed obsolete in the cobol 1985 standard and deleted in 2002 hello world a hello world program in cobol identification division programid helloworld procedure division display hello world when the now famous hello world program example in the c programming language was first published in 1978 a similar mainframe cobol program sample would have been submitted through jcl very likely using a punch card reader and 80 column punch cards the listing below with an empty data division was tested using gnulinux and the system370 hercules emulator running mvs 38j the jcl written in july 2015 is derived from the hercules tutorials and samples hosted by jay moseley in keeping with cobol programming of that era hello world is displayed in all capital letters cobuclg job 001cobol base test 00010000 classamsgclassamsglevel11 00020000 basetest exec cobuclg 00030000 cobsysin dd 00040000 00000 validation of base cobol install 00050000 01000 identification division 00060000 01100 programid hello 00070000 02000 environment division 00080000 02100 configuration section 00090000 02110 sourcecomputer gnulinux 00100000 02120 objectcomputer hercules 00110000 02200 specialnames 00120000 02210 console is consl 00130000 03000 data division 00140000 04000 procedure division 00150000 04100 00main 00160000 04110 display hello world upon consl 00170000 04900 stop run 00180000 lkedsyslib dd dsnamesys1coblibdispshr 00190000 dd dsnamesys1linklibdispshr 00200000 gosysprint dd sysouta 00210000 00220000 after submitting the jcl the mvs console displayed 195248 job 3 hasp100 cobuclg on reader1 cobol base test 195248 job 3 ief677i warning messages for job cobuclg issued 195248 job 3 hasp373 cobuclg started init 1 class a sys bsp1 195248 job 3 iec130i syspunch dd statement missing 195248 job 3 iec130i syslib dd statement missing 195248 job 3 iec130i syspunch dd statement missing 195248 job 3 iefactrt stepname procstep program retcode 195248 job 3 cobuclg basetest cob ikfcbl00 rc 0000 195248 job 3 cobuclg basetest lked iewl rc 0000 195248 job 3 hello world 195248 job 3 cobuclg basetest go pgmdd rc 0000 195248 job 3 hasp395 cobuclg ended line 10 of the console listing above is highlighted for effect the highlighting is not part of the actual console output the associated compiler listing generated over four pages of technical detail and job run information for the single line of output from the 14 lines of cobol criticism and defense lack of structure in the 1970s adoption of the structured programming paradigm was becoming increasingly widespread edsger dijkstra a preeminent computer scientist wrote a letter to the editor of communications of the acm published 1975 entitled how do we tell truths that might hurt in which he was critical of cobol and several other contemporary languages remarking that the use of cobol cripples the mind in a published dissent to dijkstras remarks the computer scientist howard e tompkins claimed that unstructured cobol tended to be written by programmers that have never had the benefit of structured cobol taught well arguing that the issue was primarily one of training one cause of spaghetti code was the go to statement attempts to remove go tos from cobol code however resulted in convoluted programs and reduced code quality cobol programs were infamous for being monolithic and lacking modularization cobol code could only be modularized through procedures which were found to be inadequate for large systems it was impossible to restrict access to data meaning a procedure could access and modify any data item furthermore there was no way to pass parameters to a procedure an omission jean sammet regarded as the committees biggest mistake another complication stemmed from the ability to perform thru a specified sequence of procedures this meant that control could jump to and return from any procedure creating convoluted control flow and permitting a programmer to break the singleentry singleexit rule this situation improved as cobol adopted more features cobol74 added subprograms giving programmers the ability to control the data each part of the program could access cobol85 then added nested subprograms allowing programmers to hide subprograms further control over data and code came in 2002 when objectoriented programming userdefined functions and userdefined data types were included nevertheless much important legacy cobol software uses unstructured code which has become unmaintainable it can be too risky and costly to modify even a simple section of code since it may be used from unknown places in unknown ways compatibility issues cobol was intended to be a highly portable common language however by 2001 around 300 dialects had been created cobol85 was not fully compatible with earlier versions and its development was controversial joseph t brophy the cio of travelers insurance spearheaded an effort to inform cobol users of the heavy reprogramming costs of implementing the new standard verbose syntax cobol kohbol n a weak verbose and flabby language used by code grinders to do boring mindless things on dinosaur mainframes its very name is seldom uttered without ritual expressions of disgust or horror the jargon file 448 cobol syntax has often been criticized for its verbosity proponents say that this was intended to make the code selfdocumenting easing program maintenance the desire for readability led to the use of englishlike syntax and structural elements such as nouns verbs clauses sentences sections and divisions yet by 1984 maintainers of cobol programs were struggling to deal with incomprehensible code jean sammet a shortrange committee member noted that little attempt was made to cater to the professional programmer in fact people whose main interest is programming tend to be very unhappy with cobol which she attributed to cobols verbose syntax isolation from the computer science community the cobol community has always been isolated from the computer science community no academic computer scientists participated in the design of cobol all of those on the committee came from commerce or government computer scientists at the time were more interested in fields like numerical analysis physics and system programming than the commercial fileprocessing problems which cobol development tackled later cobol suffered from a shortage of material covering it it took until 1963 for introductory books to appear with richard d irwin publishing a college textbook on cobol in 1966 in contrast in 2003 cobol featured in 80 of information systems curricula in the united states the same proportion as c and java there was also significant condescension towards cobol in the business community from users of other languages for example fortran or assembler implying that cobol could be used only for nonchallenging problems concerns about the design process doubts have been raised about the competence of the standards committee shortterm committee member howard bromberg said that there was little control over the development process and that it was plagued by discontinuity of personnel and a lack of talent cobol standards have repeatedly suffered from delays cobol85 arrived five years later than hoped cobol 2002 was five years late and cobol 2014 was six years late to combat delays the standard committee allowed the creation of optional addenda which would add features more quickly than by waiting for the next standard revision however some committee members raised concerns about incompatibilities between implementations and frequent modifications of the standard influences on other languages cobols data structures influenced subsequent programming languages its record and file structure influenced pli and pascal and the redefines clause was a predecessor to pascals variant records explicit file structure definitions preceded the development of database management systems and aggregated data was a significant advance over fortrans arrays picture data declarations were incorporated into pli with minor changes cobols copy facility although considered primitive influenced the development of include directives the focus on portability and standardization meant programs written in cobol could be portable and facilitated the spread of the language to a wide variety of hardware platforms and operating systems computer programming portal cobol compilers programming language genealogies alphabetical list of programming languages comparison of programming languages codasyl notes citations mwparseroutput refbeginfontsize90marginbottom05emmwparseroutput refbeginhangingindentsulliststyletypenonemarginleft0mwparseroutput refbeginhangingindentsullimwparseroutput refbeginhangingindentsdlddmarginleft0paddingleft32emtextindent32emliststylenonemwparseroutput refbegin100fontsize100 bemer bob 1971 a view of the history of cobol pdf honeywell computer journal honeywell 5 3 retrieved 28 june 2014 beyer kurt 2009 grace hopper and the invention of the information age mit press isbn9780262013109 lccn2008044229 brown william r 1 december 1976 cobol in belzer jack holzman albert g kent allen encyclopedia of computer science and technology volume 5 crc press isbn9780824722555 carr donald e kizior ronald j 31 december 2003 continued relevance of cobol in business and academia current situation and comparison to the year 2000 study pdf information systems education journal aitp 1 52 issn1545679x retrieved 4 august 2014 codasyl july 1969 codasyl cobol journal of development 1968 national bureau of standards issn05910218 lccn73601243 conner richard l 14 may 1984 cobol your age is showing computerworld international data group 18 20 id7id18 issn00104841 cutler gary 9 april 2014 gnu cobol programmers guide pdf 3rd ed retrieved 25 february 2014 garfunkel jerome 1987 the cobol 85 example book wiley isbn0471804614 isoiec jtc 1sc 22wg 4 4 december 2001 isoiec is 19892001 programming language cobol iso archived from the original zip of pdf on 24 january 2002 retrieved 2 september 2014 isoiec jtc 1sc 22wg 4 31 october 2014 incitsisoiec 19892014 programming language cobol incits klein william m 4 october 2010 the history of cobol pdf archived from the original pdf on 7 january 2014 retrieved 7 january 2014 marcotty michael 1978 wexelblat richard l ed transcript of question and answer session history of programming languages academic press published 1981 p263 doi1011458000251198370 isbn0127450408 subscription required help mccracken daniel d golden donald g 1988 a simplified guide to structured cobol programming 2nd ed wiley isbn0471610542 lccn87034608 riehle richard l august 1992 perform considered harmful communications of the acm acm 35 8 125128 doi101145135226376106 subscription required help sammet jean e may 1961 a method of combining algol and cobol papers presented at the may 911 1961 western joint ireaieeacm computer conference acm pp379387 doi10114514606901460734 subscription required help sammet jean e 1978a wexelblat richard l ed the early history of cobol history of programming languages academic press published 1981 doi1011458000251198367 isbn0127450408 subscription required help sammet jean e 1978b wexelblat richard l ed transcript of presentation history of programming languages academic press published 1981 doi1011458000251198368 isbn0127450408 subscription required help sammet jean e 23 july 2004 cobol in reilly edwin d concise encyclopedia of computer science wiley isbn9780470090954 oclc249810423 shneiderman b october 1985 the relationship between cobol and computer science annals of the history of computing ieee 7 4 348352 doi101109mahc198510041 cobolat wikipedias sister projects definitions from wiktionary media from wikimedia commons textbooks from wikibooks resources from wikiversity data from wikidata cobol at curlie gnucobol online vintage cobol compiler for a quick test drive vteprogramming languages comparison timeline history apl assembly basic c c c cobol fortran go groovy haskell java javascript js kotlin lisp lua objectivec pascal perl php python ruby rust shell smalltalk swift visual basic net vbnet more category lists alphabetical categorical generational nonenglishbased vteiso standards mwparseroutput noboldfontweightnormalby standard numberlist of iso standards iso romanizations iec standards19999 1 2 3 4 5 6 7 9 16 17 31 0 1 2 3 4 5 6 7 8 9 10 11 12 13 128 216 217 226 228 233 259 269 302 306 361 428 500 518 519 639 1 2 3 5 6 646 657 668 690 704 732 764 838 843 860 898 965 999 1000 1004 1007 10731 1155 1413 1538 1629 1745 1989 2014 2015 2022 2033 2047 2108 2145 2146 2240 2281 2533 2709 2711 2720 2788 2848 2852 3029 3103 3166 1 2 3 3297 3307 3601 3602 3864 3901 3950 3977 4031 4157 4165 4217 4909 5218 5426 5427 5428 5725 5775 5776 5800 5964 6166 6344 6346 6385 6425 6429 6438 6523 6709 6943 7001 7002 7010 7027 7064 7098 7185 7200 7498 1 7637 7736 7810 7811 7812 7813 7816 7942 8000 8093 8178 8217 8373 85011 8571 8583 8601 8613 8632 8651 8652 8691 88058806 8807 88205 8859 1 2 3 4 5 6 7 8 8i 9 10 11 12 13 14 15 16 8879 90009001 9036 9075 9126 9141 9227 9241 9293 9314 9362 9407 9506 9529 9564 95929593 9594 9660 97971 9897 9899 9945 9984 9985 9995 1000019999 10005 10006 10007 10116 101183 10160 10161 10165 10179 10206 10218 10303 11 21 22 28 238 10383 10487 10585 10589 10646 10664 10746 10861 10957 10962 10967 11073 11170 11179 11404 11544 11783 11784 11785 11801 11898 11940 2 11941 11941 tr 11992 12006 12182 12207 122342 13211 1 2 13216 13250 13399 134062 13450 13485 13490 13567 13568 13584 13616 14000 14031 14224 14289 14396 14443 14496 2 3 6 10 11 12 14 17 20 14644 14649 14651 14698 14750 14764 14882 14971 15022 15189 15288 15291 15292 15398 15408 15444 3 15445 15438 15504 15511 15686 15693 15706 2 15707 15897 15919 15924 15926 15926 wip 15930 16023 16262 166122 16750 16949 ts 17024 17025 17100 17203 17369 17442 17799 18000 18004 18014 18245 18629 18916 19005 19011 19092 1 2 19114 19115 19125 19136 19407 19439 19500 19501 19502 19503 19505 19506 19507 19508 19509 19510 19600 19752 19757 19770 197751 197945 19831 20000 20000 20022 20121 20400 21000 21047 21500 218272002 22000 23270 23271 23360 24517 24613 24617 24707 25178 25964 26000 26300 26324 27000 series 27000 27001 27002 27006 27729 28000 29110 29148 291992 29500 30170 31000 32000 38500 40500 42010 55000 80000 1 2 3 category authority control bnf cb11941315s data gnd 40103237 lccn sh85027548 net framework portal 