You are on page 1of 8

COBOL Programming Standards


The PROGRAM-ID should be an eight character descriptive name of the
The AUTHOR must be the name of the student.
The date must include DATE-COMPILED.
There must be remarks divided into specific paragraphs as indicated. The
paragraph titles should be displayed in column twelve with the rest of the
paragraph indented for clarity.
FUNCTION. Briefly state the function of the program.
INPUT FILES. List the internal name for each file used as input,
followed by its disk file name and the sort sequence (if any) of the
OUTPUT FILES. List the internal name for each file used for
output, followed by its disk file name and the sort sequence (if
any) of the file.

PRINTER OUTPUT. Describe briefly each report generated by
this program, including information about control breaks.


INPUT-OUTPUT SECTION. Select files by the order in which they are used.


Insert a blank line before each 01 level number.
Level numbers.

WORKING-STORAGE SECTION. Record names should be formulated to include the file description name and the word "RECORD". FILE SECTION. VALUE clauses must be vertically aligned in the program. . . 10. Begin all data names with "A". etc. PICTURE clauses must be vertically aligned in the program. It should be alphanumeric unless used for computation. The PICTURE of a data item should agree with its primary usage. 01 FLAGS. Files should be defined in the same sequence as they were selected in the ENVIRONMENT DIVISION. Data names should be grouped under the 01 levels in the following order and prefixed as follows: 01 ACCUMULATORS. subscription or editing. PICTURE clause. 15). counters. You should use Signed Numeric fields in all cases except for subscripts. Begin all data names with "C". Indent each higher level number four columns or other standard number of spaces. The file names should be descriptive of the function of the file. Indent NO FEWER than four spaces. 01 CONSTANTS.Use non-contiguous level numbers in increments of five (05. Data items under the 01 level should be formulated to include a two character prefix that associates the data name with its record. Data names should be descriptive of the function of the item.

01 WORK-AREAS.) Data names under each 01 level should be formulated to include a two (or more. Must be last entry in WORKING- Data items that cannot logically be grouped in the above categories should be appropriately grouped and inserted in the above list in alphabetical order by the 01 level data name. 01 PRINT-LINES. gaps should be left between numbers to facilitate program maintenance. . Begin each with an ascending four digit number indicating the sequence of the paragraph or section within the hierarchy chart. Begin all data names with "P". Use meaningful paragraph and section names. and constant values used for print lines or screens. 2000-COMPUTE-TAX. 01 TABLES. PROCEDURE DIVISION. look-up tables. (With the exception of 01 TABLES which is always the last entry. For example: First paragraph should be a 0000-MAIN. Begin all data names with "T". if necessary) character prefix that associates the data name with its record. The number should be followed by a dash and the descriptive name.Begin all data names with "F". There should be no Value clauses in the File Section except for 88-level entries. I. Begin all data names with "W". General. STORAGE. WORKING-STORAGE elementary items should NOT have initial values except for constants. This paragraph may have a ‘next level’ set of paragraphs (that it invokes (calls)) such as: 1000-INITIALIZE. which we will discuss.

Don't let the program control fall through from one paragraph to the next. Ifs. Use a separate line for the following: An ELSE conditional statement Verbs with multiple conditions: READ INPUT-FILE AT END MOVE "Y" TO S-EOF-INPUT PERFORM 3200-OUT-OF-INPUT END-READ. You may alternately use the in-line PERFORM. See separate description of a Sample Program. The WRITE . Use indentations of four spaces to the left for each continuation line of statements that exceed one line. Start each verb on a new line. trailers. SCOPE TERMINATORS (ENDS OF PERFORM. This is especially appropriate for headers. READS.. PERFORMS: PERFORM each paragraph except the driver. Detail records should appear in the File Section. FROM format should be used whenever possible.3000-PRINT-REPORT. Each paragraph is to be preceded with a Flower Box: The flower box is to contain: a description of the function of the paragraph followed by the modules this paragraph calls followed by a listing of the modules that called this paragraph. AND SEVERAL OTHER CONSTRUCTS ARE ABSOLUTELY REQUIRED!!! .. and other constant or nearly-constant records.

A paragraph has only one entry point and one exit point. You may optionally code a series of sequential MOVE statements aligned on the word TO. A paragraph may not consist of a single PERFORM statement. Multiple LINKAGE areas in a USING statement CALL "COBSUB2" USING LINK-AREA-1 LINK-AREA-2. . For example: (Unacceptable) ADD 1 TO A-PAGE-COUNT. . A paragraph must be a functionally independent unit of code. (Acceptable) MULTIPLY W-BASE-PAY BY 250. MOVE HEADING-LINE TO P-REPORT-LINE. MOVE ZERO TO P-LINE-COUNT.Multiple receiving fields for the same move MOVE FIELD-A TO FIELD-B FIELD-C. Modularity. Literals should only be coded when the value will never need to be modified and when the significance of that value is very obvious. Multiple files OPENed or CLOSEd OPEN INPUT INPUT-FILE TRANSACTION-FILE OUTPUT REPORT-FILE. as shown below: MOVE PAGE-NUMBER TO P-HEADER-PAGE.

. and the use of forward-pointing GOTOs was an acceptable practice. The format for IF statements is the IF condition statement on one line. To the exit of the same paragraph or section. GO TO. Older COBOL programs consisting of the performing of paragraph groups used this technique a great deal. COMPUTE statements should contain parentheses to insure proper ordering of computations. Use of mixed mode (negative and positive) is discouraged.Not allowed in this course. Statements involving fields with decimals should use the ROUNDED option. Avoid the use of a "NOT" in a compound IF statement. IF condition statement action statement ELSE action statement END-IF ALL IF Statements must be properly indented and contain scope terminators. the ELSE aligned with the IF on a separate line and the ELSE action statement on a separate line indented four spaces. But in the past: In structured programming every effort should be made to avoid the use of the GO TO statement. the action statement on the second line indented four spaces. Keep arithmetic statements as simple as possible. When their use is required. . If a GO TO can not be avoided the only valid uses of the GO TO are: In a downward direction within the same paragraph or section. Compound IF statements should be avoided. use parentheses for clarity.IF. Arithmetic statements.

) A row of asterisks with the phrase "END OF REPORT" centered on a line. ****************************************************** **** STATISTICAL INFORMATION ****************************************************** **** 9999 9999 9999 PERSONNEL INPUT RECORDS READ PERSONNEL OUTPUT RECORDS WRITTEN RECORDS IN ERROR Prepared by Behrooz Seyed-Abbassi. etc. . Page headings should appear on every page and should be centered. as these are normally found on report headers. The end of each report should be clearly indicated by: A double space after the last line of the report (before the statistics. etc. Diana Stewart. if required. Robert F. Additional quality control information should be collected as needed (total number of errors. and Ron Zucker. (may be required from time to time) Maintain counts of all records from input files and of all record written to output files. prepared dates. ******************END OF REPORT******************** Quality control.Output. will be discussed in class. as of dates.) Print all counts at the end of each report or job process. Jack Leitner. Page numbers. Roggio.

edu(click to send mail) Significantly updated on 12/30/2005 by R. Roggio. comments please email to rzucker@unf. .Additions. corrections.