Procedure Division [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Procedure Division
General Description
The Procedure Division can contain declarative and non-declarative
procedures.
Declaratives.
Declarative sections must be grouped at the beginning of the Procedure
Division preceded by the key word DECLARATIVES and followed by the key
words END DECLARATIVES. (See the section "The USE Statement" in the
chapters File Input and Output and Debug and Interactive Debugging.)
Procedures.
A procedure is composed of a paragraph, a group of successive paragraphs,
a section, or a group of successive sections within the Procedure
Division. A procedure-name is a word used to refer to a paragraph or
section in the source program in which it occurs. It consists of a
paragraph-name (which can be qualified) or a section-name.
The end of the Procedure Division and the physical end of the program is
that physical position in a COBOL source program after which no further
procedures appear , or the occurrence of the END PROGRAM header,
whichever occurs first (ANS85)
A section consists of a section header followed by zero, one, or more
successive paragraphs. A section ends immediately before the next
section, at the end of the Procedure Division or at the key words END
DECLARATIVES in the declaratives portion of the Procedure Division.
________________________________________________________________________
|(MF) (OSVS) (VSC2) |
|A section can consist of sentences that are not in paragraphs. |
________________________________________________________________________
A paragraph consists of a paragraph-name followed by a period and a
space, and by zero, one, or more successive sentences. A paragraph ends
immediately before the next paragraph-name or section-name, at the end of
the Procedure Division or at the key words END DECLARATIVES in the
declaratives portion of the Procedure Division.
A sentence consists of one or more statements and is terminated by a
period followed by a space.
A statement is a syntactically valid combination of words and symbols
beginning with a COBOL verb.
The term "identifier" is defined as the word or words necessary to make
unique reference to a data item.
Execution.
Execution begins with the first statement of the Procedure Division,
excluding declaratives. Statements are then executed in the order in
which they occur in the source program, except where the rules indicate
some other order.
General Format
PROCEDURE DIVISION Header
The Procedure Division is identified by and must begin with the following
header:
Procedure Division Body
The body of the Procedure Division must conform to one of the following
formats:
Statements and Sentences
There are four types of statements:
1. Conditional statements.
2. COBOL system directing statements.
3. Imperative statements.
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|4. Delimited scope statements. |
| |
________________________________________________________________________
There are three types of sentences:
1. Conditional sentences.
2. COBOL system directing sentences.
3. Imperative sentences.
Conditional Statement.
A conditional statement specifies that the truth value of a condition is
to be determined and that the subsequent action of the object program is
dependent on this truth value.
A conditional statement is one of the following:
* An EVALUATE, (ANS85) IF, SEARCH or RETURN statement
* A READ statement that specifies the AT END or INVALID KEY phrase
* An ON statement (OSVS)
* A WRITE statement that specifies the INVALID KEY or END-OF-PAGE
phrase
* A START, REWRITE or DELETE statement that specifies the INVALID
KEY phrase
* An arithmetic statement (ADD, COMPUTE, DIVIDE, MULTIPLY, SUBTRACT)
that specifies the SIZE ERROR phrase
* A RECEIVE statement that specifies a NO DATA phrase
* A STRING or UNSTRING statement that specifies the ON OVERFLOW
phrase
* A CALL statement that specifies the ON OVERFLOW or ON EXCEPTION
(ANS85) phrase
Conditional Sentence.
A conditional sentence is a conditional statement, optionally preceded by
an imperative statement, terminated by a period followed by a space.
The COBOL System-Directing Statement.
A COBOL system-directing statement consists of a directing verb and its
operands. The directing verbs are:
COPY (See "The COPY Statement" in the chapter
Compiler Directing Statements.)
ENTER (See "The ENTER Statement" in the chapter The
Nucleus.)
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|REPLACE (See "The REPLACE Statement" in the chapter |
| Compiler Directing Statements.) |
| |
________________________________________________________________________
USE (See "The USE Statement" in the chapter File
Input and Output.)
________________________________________________________________________
|(OSVS) (VSC2) |
| |
| |
| |
|BASIS (See "The BASIS Mechanism" in the chapter |
| Compiler Directing Statements.) |
| |
|DELETE (See "The BASIS Mechanism" in the chapter |
| Compiler Directing Statements.) |
| |
|INSERT (See "The BASIS Mechanism" in the chapter |
| Compiler Directing Statements.) |
| |
________________________________________________________________________
________________________________________________________________________
|(VSC2) (OSVS) (MF) |
| |
| |
| |
|EJECT (See "The EJECT Statement" in the chapter |
| Compiler Directing Statements.) |
| |
|SKIP1 (See SKIP1 Statement in the chapter Compiler |
| Directing Statements.) |
| |
|SKIP2 (See SKIP2 Statement in the chapter Compiler |
| Directing Statements.) |
| |
|SKIP3 (See SKIP3 Statement in the chapter Compiler |
| Directing Statements.) |
| |
________________________________________________________________________
________________________________________________________________________
|(VSC2) (MF) |
| |
| |
| |
|TITLE (See TITLE Statement in the chapter Compiler |
| Directing Statements.) |
| |
________________________________________________________________________
A COBOL system directing statement causes your COBOL system to take a
specified action during creation of the object code.
The COBOL System-Directing Sentence.
A COBOL system-directing sentence is a single directing statement
terminated by a period followed by a space.
Imperative Statement.
An imperative statement indicates a specific unconditional action to be
taken by the object program. An imperative statement is any statement
that is neither a conditional statement nor a COBOL system directing
statement. An imperative statement can consist of a sequence of
imperative statements, each possibly separated from the next by a
separator.
The imperative verbs are:
ACCEPT ENABLE RELEASE
ADD1 EXIT REWRITE2
ALTER GO TO SEND
CALL3 INSPECT SET
CANCEL MERGE SORT
CLOSE MOVE START2
COMPUTE1 MULTIPLY1 STOP
DELETE2 OPEN STRING3
DISABLE PERFORM SUBTRACT1
DISPLAY READ5 UNSTRING3
DIVIDE1 RECEIVE4 WRITE6
1- Without the optional SIZE ERROR phrase.
2- Without the optional INVALID KEY phrase.
3- Without the optional ON OVERFLOW phrase.
4- Without the optional NO DATA phrase.
5- Without the optional AT END phrase or INVALID KEY phrase.
6- Without the optional INVALID KEY phrase or END-OF-PAGE phrase.
_________________________________________________________________________
|(ANS85) |
|The ANSI'85 imperative verbs are: |
| |
| |
|CONTINUE INITIALIZE PURGE |
| |
_________________________________________________________________________
_________________________________________________________________________
|(OSVS) |
|The OS/VS imperative verbs are: |
| |
| |
|EXAMINE GOBACK TRANSFORM |
|EXHIBIT |
| |
_________________________________________________________________________
________________________________________________________________________
|(VSC2) |
|The VS COBOL II imperative verb is: |
| |
|GOBACK |
________________________________________________________________________
________________________________________________________________________
|(MF) |
|The imperative verbs available to this COBOL system are: |
| |
|NEXT SENTENCE |
|CHAIN |
|GOBACK |
|EXHIBIT |
________________________________________________________________________
When "imperative-statement" appears in the general format of statements,
"imperative-statement" refers to that sequence of consecutive imperative
statements that must be ended by a period or by any phrase associated
with a statement containing that "imperative-statement".
________________________________________________________________________
|(OSVS) |
|The connective word "THEN"can optionally be placed between any two |
|imperative statements which appear in a single sequence of imperative |
|statements. |
________________________________________________________________________
Delimited Scope Statements.
________________________________________________________________________
|(ANS85) |
|A delimited scope statement is a statement (for example, an IF |
|statement) which is terminated by (that is, has its end-point |
|determined by) a matching explicit scope terminator (in this case |
|END-IF). Thus, all the statements between a delimited scope statement |
|and its paired explicit scope terminator are deemed to be contained |
|within that delimited scope statement. |
| |
|Delimited scope statements can be nested, in which case each explicit |
|scope terminator encountered in the program is considered to pair |
|with the nearest preceding unpaired matching delimited scope |
|statement. |
| |
|Scope delimited statements can also be implicitly terminated, either |
|at the end of a procedural sentence (where all unterminated statements|
|are terminated by the separator period), or by the termination of any |
|containing delimited scope statement. |
| |
|Note that not all statements are scope delimitable in this fashion; |
|those statements that are scope delimitable are only termed delimited |
|scope statements if they are explicitly terminated by an explicit |
|scope delimiter. |
| |
|See "Explicit and Implicit Scope Terminators" in this chapter for |
|further information. |
________________________________________________________________________
Imperative Sentence.
An imperative sentence is an imperative statement terminated by a period
followed by a space.
Categories of Statements.
IF and ON are verbs in the COBOL sense; it is recognized that they are
not verbs in English.
MPE/iX 5.0 Documentation