There are four categories of COBOL statements:
An imperative statement either specifies an unconditional action to be taken by the program, or is a conditional statement terminated by its explicit scope terminator (see Delimited Scope Statements). A series of imperative statements can be specified whenever an imperative statement is allowed.
Table 28 lists COBOL imperative statements.
Table 28. Types of Imperative Statements
| Type | Imperative Statement |
|---|---|
| Arithmetic |
ADD1 COMPUTE1 DIVIDE1 INSPECT (TALLYING) MULTIPLY1 SUBTRACT1 |
| Data Manipulation |
ACCEPT (DATE, DAY, DAY-OF-WEEK, TIME) INITIALIZE INSPECT (CONVERTING) INSPECT (REPLACING) MOVE SET STRING2 UNSTRING2 +-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
|
| Ending |
STOP RUN EXIT PROGRAM +-------------------------------IBM Extension--------------------------------+ GOBACK +----------------------------End of IBM Extension----------------------------+
|
| Input/Output |
ACCEPT6 identifier CLOSE DELETE3 DISPLAY6 OPEN READ4 REWRITE3 SET (for UPSI switches) START3 STOP literal WRITE5 +-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
|
| Ordering |
MERGE RELEASE RETURN SORT |
| Procedure Branching |
ALTER EXIT GO TO PERFORM |
| Subprogram Linkage |
CALL7 CANCEL |
| Table Handling | SET |
Notes to Table 28:
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. (See Conditional Expressions.)
Figure 14 lists COBOL statements that are conditional, or that become conditional when a condition is included (for example: ON SIZE ERROR, or ON OVERFLOW) and the statement is not terminated by its explicit scope terminator.
Figure 14. Conditional Statements
Arithmetic Ordering ADD...ON SIZE ERROR RETURN...AT END ADD...NOT ON SIZE ERROR RETURN...NOT AT END COMPUTE...ON SIZE ERROR COMPUTE...NOT ON SIZE ERROR DIVIDE...ON SIZE ERROR DIVIDE...NOT ON SIZE ERROR MULTIPLY...ON SIZE ERROR MULTIPLY...NOT ON SIZE ERROR SUBTRACT...ON SIZE ERROR SUBTRACT...NOT ON SIZE ERROR Data Manipulation Subprogram Linkage STRING...ON OVERFLOW CALL...ON OVERFLOW STRING...NOT ON OVERFLOW CALL...ON EXCEPTION UNSTRING...ON OVERFLOW CALL...NOT ON EXCEPTION UNSTRING...NOT ON OVERFLOW+-------------------------------IBM Extension--------------------------------+ |
A delimited scope statement uses an explicit scope
terminator to turn a conditional statement into an imperative statement; the resulting imperative statement can then be nested. Explicit scope terminators may also be used to terminate the scope of an imperative statement. Explicit scope terminators are provided for all COBOL verbs that may have conditional phrases.
Unless explicitly specified otherwise, a delimited scope statement may be specified wherever an imperative statement is allowed by the rules of the language.
Related Information:
An explicit scope terminator marks the end of certain Procedure Division statements. A conditional statement that is delimited by its explicit scope terminator is considered an imperative statement and must follow the rules for imperative statements.
The following are explicit scope terminators:
END-ACCEPT END-PERFORM END-ADD END-READ END-CALL END-RETURN END-COMPUTE END-REWRITE END-DELETE END-SEARCH END-DISPLAY END-START END-DIVIDE END-STRING END-EVALUATE END-SUBTRACT END-IF END-UNSTRING END-MULTIPLY END-WRITE
+-------------------------------IBM Extension--------------------------------+
END-XML
+----------------------------End of IBM Extension----------------------------+
The separator period at the end of any sentence is an implicit scope terminator that terminates the scope of any previous statement that is not yet terminated. When a statement is contained within another statement, the next phrase of the containing statement following the contained statement is an implicit scope terminator that ends the scope of the contained statement.
A conditional statement not terminated by its scope terminator cannot be contained within another statement.
Except for nesting conditional statements within IF statements, nested statements must be imperative statements, and must follow the rules for imperative statements. You should not nest conditional statements.
These are statements that direct the compiler to take a specified
action. They are discussed in Compiler-Directing Statements.
| Type | Compiler-Directing Statement |
|---|---|
| Library | COPY |
| Declarative | USE |
| Documentation | ENTER |
| Compiler options | PROCESS |
| Source text | REPLACE |
| Source Listing | +-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
|
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.