01 TABLE-AREAS.
05 L-LOCATION-LIST.
10 FILLER PIC X(12) VALUE "1BOSTON".
10 FILLER PIC X(12) VALUE "2NEW YORK".
10 FILLER PIC X(12) VALUE "3WASHINGTON".
10 FILLER PIC X(12) VALUE "4ATLANTA".
10 FILLER PIC X(12) VALUE HIGH-VALUES.
05 L-LOCATION-ARRAY REDEFINES L-LOCATION-LIST
10 L-LOCATION-TABLE OCCURS 5 TIMES
ASCENDING KEY L-TABLE-CODE
INDEXED BY LX, LX2, LX3.
15 L-TABLE-CODE PIC X.
15 L-TABLE-NAME PIC X(11).
05 LX-MAX PIC S9999 COMP SYNC VALUE 5.
05 L-ENTRY.
10 L-ENTRY-CODE PIC X.
10 L-ENTRY-NAME PIC X(11). COPY
areas appear at the end of working-storage,
just before the LINKAGE SECTION, if it exists.
PROCEDURE DIVISION.
Modularity. Each program is modularized functionally into
five types of paragraphs or sections:
Control. Selects other modules to be performed.
Housekeeping. Opens/closes files; initializes areas,
records, and tables; performs beginning or ending
tasks.
Process. Manipulates data, either within itself, if the
task is simple, or through the performance of other
processes. (To the extent it does the latter, it
becomes a Control module.)
Input/Output. Reads or writes records and executes
certain end of file procedures.
Utility. Prints error messages, does table lookups, or
does other kinds of processing that may be required
at more than one point in the program.
Hierarchical Dependence. The MAIN module, which appears first,
controls the overall logic of the program. (Paragraphs are
preferred over Sections, which are used only if required by
the compiler, such as when external sorting is performed.)
The MAIN paragraph performs first-level modules,
which are named beginning with a single non-zero digit
followed by a functional name or mnemonic, separated by a
dash. First level modules that involve roughly more than 20
non-trivial lines of instruction are broken logically into
Second level lower modules that are performed from the First
level.
Second level paragraphs will be named with the same
1st digit as the performing routine, followed with a second
digit of its own. Similarly, each Second level routine may
perform Third level routines, which will have three digit
prefixes and so on.
These level modules constitute a strict tree structure.
Each module in the tree is performed by one and only one
higher level (lower numbered) module, but may itself perform
one or more lower level (higher numbered) modules.
Those functions that must be performed from several
branches of the tree--whether Process, I/O, Housekeeping,
or Utility--are grouped at the end of the program and given
functional names or mnemonics.
Calls to subroutines are grouped in separate paragraphs
at the very end of the program and performed as needed.
Control Conventions.
PERFORM, PERFORM __ UNTIL, and PERFORM __ VARYING __
UNTIL
are the principal means to control program looping,
and to conduct execution of lower level modules.
GO TO's are avoided. One may be used (rarely) for
exception branching, such as GO TO ABORT-EXIT. The preferred
way of handing such exceptions is to set a flag that is
tested at a higher level and acted upon there.
IF
statements are used as required for selective
processing, but when compound or nested IF statements result
in code that is difficult to interpret, PERFORM's are
introduced.
ALTER statements are not used.
An Example of a Naming Convention
This is the naming convention adopted in TeleMar's
TeleMarshal® Telephone Management System for six character
program names and copy library (COPYLIB) data packet names.
Position 1-2 mnemonic (TM for TeleMarshal)
Position 3 0 (zero) Mainline Programs
S Subroutine Subprograms
W COPYLIB - Working-Storage areas
L COPYLIB - Linkage areas
P COPYLIB - Procedure areas
Position 4 0 Programs - Utility
1 Programs - Daily/Monthly
2 Programs - Telco Billing/Equip
3 Programs - Call Accounting
4 Programs - Traffic Analysis
D Subprograms - Database
H Subprograms - Help
I Subprograms - Input
O Subprograms - Output
P Subprograms - Processing
T Subprograms - Table
U Subprograms - Update
Z Subprograms - Intrinsic
D COPYLIB - Database Area
or Detail Record
F COPYLIB - File Record
M COPYLIB - Master Record
S COPYLIB - Save Area
Position 5-6 Numeric Programs - Serial Number
Alpha/numeric Subprograms - Function Mnemonic
COPYLIB - Function Mnemonic
All data items in COPYLIB have 3 character prefixes
that are the same as position 4-6 of the packet name, except
for the name of the level 01 item, which is the same as the
six-character packet name.
Programs which call subroutines use position 4-6 of
subroutine name as the prefix in the name of the paragraph at
the end of the program that contains the subroutine call.
See the