Quality Aspects to Check While Writing COBOL Program
This article gives a general list which the programmer must check while delivering programs developed in COBOL. This can also be used as a general checklist for checking quality of the COBOL program developed.
Quality is a vital factor for all deliverables in software. This is because of the following reasons:
- To improve the quality of deliverables
- To ensure completeness of deliverables
- To ensure correctness of deliverables
- To improve maintainability
- To minimize orientation and study time
- To make timely delivery
- To reduce the cost of a task
COBOL is a language Oriented towards Business applications. It is a high level language which is Machine Independent. It is an English like language which is self documenting and so easy to learn, write, read and maintain.
General List for Checking while developing COBOL Programs
Has the program log been given proper description?
Have the working storage variables been initialized?
Have the DCL working storage copybooks been included?
Have the DCL indicator variable copybooks been included?
If it is a migration program check whether country specific values are correct?
Has validation been performed for the input values retrieved from input sources other than the database?
Have the working storage and DCL section variables been initialized in the main paragraph of the program?
Has proper documentation (if any) been given for all the paragraphs?
Is essential values been hard coded in the program?
Have the cursor variables been initialized before fetch?
Have the indicator variables been checked for nullable fields?
Has the SQL CODE been checked after every database and cursor operation?
Has the FILE STATUS been checked after every file operation?
In case of abend of an update program check whether the previous transaction alone is rolled backed or the entire set of transactions are rolled back?
Have a check whether the values to be inserted in to the error log table is correct
Does the program handle abends by terminating normally with appropriate error message insertion into the error log table. This is needed so as to track the error and handle appropriately.
Has if you have a report in your COBOL program ensure whether the message END-OF-REPORT been included at the end of report if any in the program
Is the report layout proper for no data condition in the Program?
Have naming conventions been followed?
Does the program check for duplicate conditions while inserting records into the database?
Have all the Working Storage section variables that have been declared been used in the program?
To improve performance has it been ensured that sub queries have been avoided?
Has it been ensured that every update operation is preceded by a read operation to check for the existence for the record?
In case of data retrieval failure for SQL operations have the values for which the record was not fetched been inserted in to the error log?
Ensure whether Check point/restart is used for insertion/updating programs
Has it been ensured that data truncation does not happen during program operations?
If the Program is creating any Report, has it been taken care to handle empty report also?
Is there proper checking in the Program to handle empty files?
Whether all the ‘Display’ statement in the Program, which is used at the time of Testing/Debugging, is removed?
While using user defined words take care that maximum character allowed is 30 characters. And it can contain only digits, letters and hyphens. Care must be taken that it must not be a reserved word. Also user defined words must have at least one letter and spaces are not allowed.
If Numeric Literals are used in program it can contain minimum one digit and maximum 18 digits. If in the program if the Numeric literal uses a sign it must be used as the left-most character and also there can be only one sign for a Numeric literal. Similarly if decimal is used in the Numerical Literal it cannot be used as the right-most character and also a Numeric Literal can have only one decimal.
If Non Numeric Literal s are used in COBOL program then it must be enclosed in quotes and also any character in the character set of COBOL can be used as the non numeric literal. If in a program you want to use a quote as a non numeric literal then you must use two continuous quotes to get a single quote. Maximum length that can be used for a non numeric literal is 160.
If you want to specify a very high or a very small value in a COBOL program a floating point literal is used and check must be made that it falls between 0.54E- 78 and 0.72E+76.
Check whether the following coding form is followed in your COBOL program:
Columns
1 to 6 : Sequence Number
7 : * / – (Indicator Area)
8 to 11 : Area A (Margin A 8th)
12 to 72 : Area B (Margin B 12th)
73 to 80 : Identification Field
The COBOL program normally has the following division 4 namely:
IDENTIFICATION
ENVIRONMENT
DATA
PROCEDURE
and in this SECTIONS / PARAGRAPHS is fixed for first 3 Divisions .While coding COBOL program check whether Division, Section and Paragraphs are in Area A.
The IDENTIFICATION DIVISION must have PROGRAM-ID, AUTHOR, DATE-WRITTEN, DATE-COMPILED. So always check for this. Also it must have a Comment Block explaining the function of the program. For future use it must also have a Maintenance Log Block. So ensure all this while coding this division.
The ENVIRONMENT DIVISION CONFIGURATION SECTION must have
SOURCE-COMPUTER and OBJECT-COMPUTER. In INPUT-OUTPUT SECTION Each SELECT starts at Col. 12 and blank line must be there before SELECT. Each clause of SELECT must be on a separate line and each clause starts at Col. 16.
Also care must be taken code Division names and Section names on separate lines. All other entries may have several statement combined on a single line
If you have a continuation line of Area A it must be blank. Any sentence, entry, clause, or phrase that requires more than one line can be continued in Area B of the next line but it must not be comment line or blank line.
Continuation line must contain a hyphen in the indicator area.
OCCURS can’t be defined for a data item which has a level number of 01, 66, 77, or 88. OCCURS and REDEFINES cannot be combined.
You cannot Rename 77 88 66 or 01 levels
In the Linkage Section EXTERNAL and GLOBAL clause not allowed
Check whether in Working Storage Section data names are prefixed by 1 and ensure that you have not used 66 level. Also check whether you have used value clause only for constant data items.
-R.Sripriya