Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 39

Level I VisionPLUS coding Standards

Introduction
 First Data – Coding standards to be used with all Cobol programs
 We shall cover the Cobol Coding standards for following topics
• Identification Division
• Environment Division
• Data Division
• Working Storage Section
• Procedure Division
• Table Handling

 There may be exceptional situations where deviations from these


standards are justifiable and appropriate. If deviations are necessary,
you must obtain and document appropriate managerial approval
before proceeding
Identification Division
COBOL Statement Existing Standard
Identification Division. Spell out; do not use “ID” abbreviation.
Author. Do not use.
Date compiled. Do not use.
Date written. Do not use.

Program ID clause is always included with the program


name and should begin in column 20.
Program ID. Immediately following the Program ID, type a comment
(Program Name) box (enclosed in asterisks) containing:
(Comment Box) •Name of the system
•Program name
•Program title
•Major functions.

Remarks. Do not use.


Security. Do not use.
Identification Division -
Example
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. OFD100.
000300*****************************************************************
000400* *
000500* >>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< *
000600* >>> FINANCIAL AUTHORIZATION SYSTEM <<< *
000700* >>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< *
000800* *
000900*****************************************************************
001000*
001100* ON-LINE AUTHORIZATIONS SYSTEM
001200*
001300* OFD100 - END-OF-DAY BATCH CREATE
001400*
001500* MAIN FUNCTIONS -
001600*
001700* THIS PROGRAM IS THE FIRST BATCH PROGRAM IN THE AUTHORIZATION
001800* END-OF-DAY BATCH PROCESS. IT IS USED TO CREATE A USER INPUT
Environment Division
COBOL Statement Existing Standard
Environment Division. Spell out; do not use “ID” abbreviation.

Configuration section.

Include, using the following conventions:


• Same Area may be used whenever possible
• Apply Write Only may be used whenever possible.
File Control. Begin in column 8. The file name is on the same line, but
(I-O Control) will begin in column 20. All subordinate clauses
Select (File Name) begin in column 20. Always code file status.
Assign to (File Name) The occurrence of Select statement should be in
alphabetical order of File Name.
Begin in column (20). Due to DOS constraints, the file
name cannot be longer than 7 bytes.

Source computer. Do not use.


Special names. Do not use.
Environment Division - Example
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
000800 ENVIRONMENT DIVISION.
000900 INPUT-OUTPUT SECTION.
001000 FILE-CONTROL.
013300 SELECT AMBS-FILE-SEQ
013400 ASSIGN TO AMBS
013500 ORGANIZATION INDEXED
013600 ACCESS SEQUENTIAL
013700 FILE STATUS WS-STATUS WS-RETURN
013800 RECORD KEY AMBS-SEQ-KEY.
013900*
014000 SELECT AMBS-FILE-DYN
014100 ASSIGN TO AMBS
014200 ORGANIZATION INDEXED
014300 ACCESS DYNAMIC
014400 FILE STATUS WS-STATUS WS-RETURN
014500 RECORD KEY AMBS-DYN-KEY.
Environment Division - Example
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
015300*
015400 I-O-CONTROL.
015500*
015600 SAME AREA FOR
015700 AMBS-FILE-SEQ
015800 AMBS-FILE-DYN
015900 AMBS-FILE-RDM.
Data Division
COBOL Statement Existing Standard
Data Division.

File Section.

FD (File name) Begin in column 8. All other file description


(File Description entry) clauses begin in column 12. All FD statement
(Record Description should be in the same sequence as the Select
entry) statements.
(Block Contains clause) Use for all sequential tape and disk records,
(Data Record clause) except when recording mode is U (use
(Data /Record Is/ characters).
/Records Are/) Do not use.
Do not use.
(/Report Is Do not use.
/Reports Are/) Do not use.
(Linkage Is) Use.
(Record Contains Use for all sequential tape and disk records,
clause) except when recording mode is U (use
(Recording Mode clause) characters).
Data Division
COBOL Statement Existing Standard

Level numbers:
Level Numbers. • Begin with 01 in column 8 and increment by 2,
01 (Record name) going up as high as necessary. For example, use
level numbers 01, 03, 05, and so forth. Always start
in a column that is an increment of 4. Indent each
increment by 4.
• Coded as two digits, followed by two spaces,
followed by a data name.
Begins in column 8, with the record name beginning in
column 12. The record name must be a group item
(does not have a picture clause).
Do not use.
Do not use.
‘66’ Levels Defines values for all non monetary data elements where
‘77’ Levels needed
‘88’ Levels Example: Always code “If condition name…” Do not
code “If data element (not equal…”

Begins in column 52. The index name follows indexed


Indexed by. by, unless the name is too long to fit on the line. In that
case, the index name should begin on the next line, in
column 52.
Data Division - Example
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
015900 DATA DIVISION.
016000*
016100 FILE SECTION.
002700 FD :AMBS:-FILE-SEQ
002800 RECORD CONTAINS 6500 CHARACTERS.
002900*
003000 01 :AMBS:-SEQ-RECORD.
003100 03 :AMBS:-SEQ-KEY.
003200 05 :AMBS:-SEQ-ORG-X.
003300 07 :AMBS:-SEQ-ORG
003400 PIC 999.
003500 88 :AMBS:-SEQ-HEADER-REC VALUE 000.
003600 88 :AMBS:-SEQ-TRAILER-REC VALUE 999.
003700 05 :AMBS:-SEQ-ACCT PIC X(19).
003800 03 FILLER PIC X(6478).
003900*
Working Storage Section
COBOL Statement Existing Standard

The first item in working storage (with correct spaces) is:


01 WS-BEGIN. (Value – Col. 52)
03 FILLER PIC X(12)
VALUE ‘** WS-BEG **’.
03 WS-PGM-ID PIC X(08)
Working Storage VALUE ‘ ’.
Section. The last item in working storage (with correct spacing) is:
01 FILLER PIC X(12)
VALUE ‘** WS-END **’.
Working storage is organized as follows:
All copybooks are in order by copybook name for each section
Miscellaneous work fields are all under a single 01 Level, and all data names begin
on a lower level (such as 03, 05, and so forth).

(Blank When Zeros) Begin in column 52.

Detail lines. All detail print lines should be redefines of the original 01 Level item. Report lines
are not defined under the FD for the print file in the data division.

Heading lines. Should not exceed the maximum number of heading lines printed on any one
report.
Working Storage Section
COBOL Statement Existing Standard
Justified (Right) Begin in column 52.
(Just)
Occurs clause. Begin in column 52. Table must be contained in a group item.
Use the abbreviation PIC and begin in column 36. Two spaces
Picture clause. after PIC for all non-signed fields, and always a 2-digit (or
more) designation - (02) not (2).
Print lines. Defined in working storage with 132 bytes each.

Redefines:
•Begins in the same column as the PIC clause
Redefines clause. •If using indexing, the indexed by clause follows the occurs
clause
•Must equal the size of the area being redefined.

Renames. Do not use.


Sign (Is) /Leading/
/Separate/ Do not use.
/Trailing/
Working Storage Section
COBOL Statement Existing Standard
Synchronized
Sync Do not use.

Use only for pointers.


Display is the default. Do not specify.
Use Index.
Usage Is /Pointer/ Use BINARY, do not use Computational or COMP.
/Display/ Use PACKED-DECIMAL not COMP-3.
/Index/ Begin BINARY or PACKED-DECIMAL in column
/Comp-3/ /Computational-3/ 52.
/Comp-1/ /Computational-1/ Do not use Usage Is Comp under the FD area, except
to define incoming or outgoing data elements of
/Comp-4/ /Computational-4/ another vendor’s files.
/Binary/ Do not use COMP-1 or COMP-4 without prior
management approval.
Within a record layout, use BINARY instead of
COMP.

Value (literal). Begin in column 52. Do not use the word ‘IS’.
Procedure Division
COBOL Statement Existing Standard

Each line of code in a Procedure Division begins in a


column that is a multiple of 4, starting in column 12.
Paragraph names are an exception. Begin paragraph
names in column 8.
Procedure Division. Except for internal sorts, do not use Sections.
If Sections are used, the first line following the
Procedure Division must be a Section label.
Split all Procedure Division statements using ‘TO’ so
that the ‘TO’ begins in column 40.

Call /Using/ Use only dynamic Calls. Do not use static Calls.
Begin Using in column 40.

Compute statements Use Compute statements instead of Add, Subtract,


Multiply and Divide statements.
End compute.
Do not use Add/Subtract statements
Procedure Division
COBOL Statement Existing Standard

Any statement that contains a combination of


the reserved words ‘AND’ and ‘OR’ must
contain parentheses around each condition.
Example:
If (A = B
Conditional expressions. AND B = C)
Combined conditions. OR (D = F
AND F = C)
Do not use multiple objects after a subject. Do
repeat the subject after the AND/OR.
Example: Do not use:
IF A = (B OR C)
Instead, use:
IF A = B
OR A = C.
Procedure Division
COBOL Statement Existing Standard

Conditional expressions.

Condition-name. Conditions beginning with ‘AND’ or ‘OR’ should


begin on the next line. ‘AND’ or ‘OR’ should be
at the beginning of the condition line (aligned
with IF).
Relation conditions. Do use symbols for greater than, less than, and
equal to (>, <, =). DO NOT use “is equal to,” “is
greater than,” and so forth.

Positive and Negative signs are not allowed.


Sign condition.
Procedure Division
COBOL Statement Existing Standard

Copy. Copy (text name) is the only format of the Copy


statement used.

Begin the Copy statement in column 12.

The COPY statement line should be preceded


by a line containing only a "/" in column 7.

Using Copy within a copybook is discouraged.

Can be used.
Replacing

Suppress Do not use.


Procedure Division
COBOL Statement Existing Standard

Display Upon Console. Do not use.

Display statement
Display (ID-1/LIT-1) Use only with the common ABEND routine and
mnemonic name /Upon to allow for multiple tape mounts.
(function-name)/

Do not use for any program. A slash (/) in


Eject column 7 accomplishes the same task.

Evaluate Should be used to replace the use of a


complicated If/Else statement.
End Evaluate. Indent four positions.

Exit statement Start in column 12, on a separate line following


Paragraph-name. the paragraph name. Do not include any other
information in the Exit paragraph.
Exit.
Procedure Division
COBOL Statement Existing Standard

Figurative constants. Use ‘space’ and ‘zero’ instead of ‘ ’ and ‘0’.

Go to statement Use a GOTO statement only in batch programs


Go to statement— when referencing an Exit.
unconditional
Go to procedure-
name-1.
Go to statement— Use only with a single common exit within a
conditional paragraph.
Go to procedure-
name-1 thru
procedure-name-n
Depending on
identifier.
Go to statement-altered. Do not use.
Procedure Division
COBOL Statement Existing Standard

Avoid greater than three levels of nested If’s. Use Evaluate


statements instead.
Do not use Next Sentence.
When using Continue or another conditional statement, begin four
columns to the right of the If.
Avoid negative conditions.
If-else statements ELSE and END-IF should be on a line of its own and aligned with its
respective If.
Do not use multiple objects after a subject. Do repeat the subject
after the and/or.
End-If. Example:
Do not use: IF A = (B OR C)
Instead, use: IF A = TO B
AND A = TO C.
Conditions beginning with ‘AND’ or ‘OR’ should begin on the next
line. ‘AND’ or ‘OR’ should be at the beginning of the condition line
(aligned with IF).
Procedure Division
COBOL Statement Existing Standard

Do not use on any master records because it can cause problems


across platforms. Instead, build an initialization copybook.
Initialize
Can be used on working storage.

Insert Do not use.

Inspect May be used

The ‘To’ contained in a Move statement should begin in column


40.
If there are multiple receiving identifiers, each should appear on a
Move line by itself, and the 'MOVE XXXX TO" should not be repeated..
For online attribute settings, multiple receivers per line are
acceptable.
Do not use Move Corresponding except in conversion programs.

Do not use in any program. Use an asterisk ‘*’ in column 7 for any
Note comments.
Procedure Division
COBOL Statement Existing Standard

Do not use Close With Lock.


Never reference any field under an FD:
– Before the file has been opened
Open/Close – After an EOF
statements – After a file has been closed
Physical – After a write
sequential files – After a delete
Open/Close (File- For non-VSAM files, when opening continuously, list files under
name-1) one Open/Close statement.
(/Reel unit/ /with Only the record key may be referenced after a file has been
no opened, but before the first record has been read.
rewind/ /for All files must be opened at the beginning of the program and
removal/ should be closed at the end of the program, except as follows:
/with no rewind/ • If a file is optional, it must not be opened until it is required.
/lock/) • If a file is used exclusively in either the input or output
procedure of a sort, it should be opened and closed inside of
the sort procedure.
Do not use the reserved option on an Open statement.
Procedure Division
COBOL Statement Existing Standard

Paragraph names begin in column 08.


Paragraph Names. A comment line that contains only an asterisk (*) in
column 7 should precede and follow Paragraph Names.

Read
/Read next/ Always use for sequential VSAM file processing.
/Invalid-key/ Do not use. Instead, use file status check.
/At End/ Do not use. Instead, use file status check.
Read Filename Into Exceptions to the Read Into are for Variable 01 Record
Identifier Layouts where the read must be into the FD to
determine the record layout needed.
End Read.

SET a condition to true, do not move a value to a


field:
Set SET WS-EOF TO TRUE
Not
MOVE 'Y' TO WS-EOF-SW.
Procedure Division
COBOL Statement Existing Standard

Perform
Basic Perform-- Code all performs using one of the following
Inline Perform-- formats:
– Perform (Imperative statements) End-
Perform Procedure-Name-1 Perform.
Thru Procedure-Name-2 – Perform (procedure name 1) through
(procedure name 2)… where procedure
Times Option-- name 2 is always a paragraph containing
Perform Procedure-Name-1 only an Exit statement.
Thru Procedure-Name-2
Begin THRU under the PERFORM:
(ID-1/LIT-1) Times. PERFORM xxxxxxxx
Conditional Perform-- THRU xxxxxxxx.
Perform Procedure-Name-1
Thru Procedure-Name-2 Do not include a GOTO in any performed
Until Condition-1. paragraph(s) that branches outside of the
Varying Option-- paragraph(s).
End Perform.
Procedure Division
COBOL Statement Existing Standard
Do not use. Use an asterisk (*) in column 7 instead.
Skip No blank lines should be coded for spacing purposes.
Sort Can be Used

Sort Return Code Should be checked to ensure successful sort.

Sort/Merge Do not use

Start
/Invalid-key/
Start File-Name Can be used for VSAM files.
(Key Is /Equal to/
Should not be used. Instead, use file status check.
/Greater than/
/Not Less than/ Avoid using Equal To.
Data name)
End Start.
Procedure Division
COBOL Statement Existing Standard

A literal should be used with the Stop statement only


when a program is processing multiple-tape files.

Stop Run There should be only one Stop Run statement in each
batch program.
Never use a Stop Run statement in an online program.
Use Go Back.

String Can be Used


Always use Go Back (instead of Exit) to return to
Subprogram Linkage calling program.

Transform Do not use

Unstring Can be used

Use After Do not use


Procedure Division
COBOL Statement Existing Standard

Write
Physical sequential files
Write record-name (from
ID)
(/Before/)
Advancing For print files:
(ID-2/Integer) Use Before Advancing instead of After Advancing
(Mnemonic name/page)
VSAM Sequential Files-- Indicate new page by ‘Page’ instead of mnemonic
Write record-name Name
(From identifier).
VSAM indexed and Do not use ‘EOP’ or ‘End-of-Page’
relative files--
Write record-name
(From identifier)
(File Status Check).
End Write.
Table Handling
COBOL Statement Existing Standard

Ascending/Descending Keys Can be used.


Delete Do not use

Indexing Index all tables to a maximum of three dimensions.

Can be used.
Initialize Do not initialize tables using overlapping operands

Occurs
Fixed Length Tables--
Occurs Integer-2 Times.
Variable Length Tables-- Use
Occurs Integer-1 to
Integer-2 Times
Depending On Data-
Name-1.
Table Handling
COBOL Statement Existing Standard

Search
Search All Can be used.
Search All Identifier-1 (At an
Imperative-statement) end-search

Set Can be used.


Direct Indexing--
Set (Index-Name-1)
(ID-1)
To
(Index-Name-3)
(ID-3)
Relative Indexing--
Set Index-Name-4
(Up by) (ID-4) "UP" starts in column 40.
(Down by) (LIT-2) "DOWN" starts in column 40.
JCL Standards
 All jobs with the exception of conversions and one-
time runs, will be PROCS.
 Restart points are documented in the PROC.
 EXEC, DD, INCLUDE, etc. will be coded in
column 12.
 DSN and all associated entries will be coded in
column 16.
Rules for Coding
Rule #1
 Only one modification or fix per TSO member name per enhancement
or fix

Rule #2

 Every custom modification member must contain a module control


card as the first line.
 This module control card should contain 'EXC' in column 16.
 Column 19 should contain 'ADD', 'UPD', or 'REP', and column 50
should contain a module type.
 The module control card should not contain 'RSQ' or 'DNM'.
Rules for Coding
Rule #3
• Any custom modifications to an existing program that
exceed ten lines of code should be placed into a copybook.

Rule #4
• All custom modification copybooks should be located either
at the end of working storage (for working storage
copybooks), or at the end of the program (for procedure
division copybooks).
Rules for Coding
Rule #5
• There will be one custom modification copybook per
modification per program, except where a copybook is
needed in-stream or is reusable in multiple programs.

Rule #6
• The program containing the procedure division or working
storage copybook should also contain a comment line prior
to the copy statement.
Rules for Coding
Rule #7
 New procedure division or working storage copybooks should
contain a comment box at the beginning of the copybook. To
make these comment boxes easily identifiable, the comment
should specify the originating programs.

Sample0....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8

******************************************************************ZH110002

* *ZH110002

* Procedure Division for Programs ARD140, ARD360 *ZH110002

* MOD002 - OPEN ITEM BILLING *ZH110002

* *ZH110002
Rules for Coding
 Rule #8

 The "++++++" lines are documentation lines contained at the beginning of a


new program or update module on all custom fixes and modifications.

 These documentation lines must be the same within all the programs,

 copybooks, etc. affected by the same modification.

 0....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8

 ++++++ - - -

 ++++++ -ZT - -mm/dd - CCSGI #0000 — Client #0000


Rules for coding
Rule #9
 Each line of code should have a valid entry in columns 73
through 80.

• Example for an enhancement # 101, project 921, columns 73- 80


should be ZH921101
• Example for a fix # 201, project 921, columns 73- 80 should be
ZX921201

 The exceptions to this rule are an 'ADD' or a 'REP' program


(Module Types COB, CCP, DMC, RMC).
Rules for Coding
Rule #10
 Do not use '-DEL' to remove lines of code already released
(base or custom) to the customer. Instead, replace the unwanted
lines of code with the addition of three asterisks (***) starting
in column 7.

Rule #11
 When modifying an existing program, attempt to maintain the
same coding style and standards. When adding new programs
or replacing existing programs, adhere to the new coding
standards.
Rules for Coding
Rule #12
 Use comments to document and explain
complex code or techniques.
Rule #13
 When adding new custom maps, add
redefinition copybooks.
• For example : ARZM01 & ARZM01R
Rules for Coding
Rule #14

 When adding new fields to the files RL/IR Copybooks, ALWAYS add the new
fields immediately below the filler.

 DO not use any USER-FILLER. They are reserved for the customer's use.

RULE #15

 When coding fixes each fix is to address one unique issue.

RULE #16

 Once a fix or enhancement has been released to QA or the customer the


original code can not be directly modified.

You might also like