ILE COBOL Language Reference

Statement Categories

There are four categories of COBOL statements:

Imperative 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--------------------------------+


XML GENERATE6
XML PARSE6

+----------------------------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--------------------------------+


ACQUIRE
COMMIT
DROP
ROLLBACK

+----------------------------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:

1
Without the ON SIZE ERROR or NOT ON SIZE ERROR phrase.

2
Without the NOT ON OVERFLOW or ON OVERFLOW phrase.

3
Without the INVALID KEY or NOT INVALID KEY phrase.

4
Without the AT END, NOT AT END, INVALID KEY, NO DATA, or NOT INVALID KEY phrase.

5
Without the INVALID KEY, NOT INVALID KEY, END-OF-PAGE, or NOT END-OF-PAGE phrase.

6
Without the ON EXCEPTION or NOT ON EXCEPTION phrase.

7
Without the ON OVERFLOW, ON EXCEPTION, or NOT ON EXCEPTION phrase.

Conditional Statements

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--------------------------------+

XML GENERATE...ON EXCEPTION XML GENERATE...NOT ON EXCEPTION XML PARSE...ON EXCEPTION XML PARSE...NOT ON EXCEPTION

+----------------------------End of IBM Extension----------------------------+

Decision  Table Handling IF SEARCH...WHEN EVALUATE Input/Output ACCEPT...ON EXCEPTION READ...NO DATA ACCEPT...NOT ON EXCEPTION REWRITE...INVALID KEY DELETE...INVALID KEY REWRITE...NOT INVALID KEY DELETE...NOT INVALID KEY START...INVALID KEY DISPLAY...ON EXCEPTION START...NOT INVALID KEY DISPLAY...NOT ON EXCEPTION WRITE...AT END~OF~PAGE READ...AT END WRITE...NOT AT END~OF~PAGE READ...NOT AT END WRITE...INVALID KEY READ...INVALID KEY WRITE...NOT INVALID KEY READ...NOT INVALID KEY

Delimited Scope Statements

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:

Explicit Scope Terminators

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----------------------------+

Implicit Scope Terminators

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.

Compiler-Directing 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--------------------------------+


*CBL
*CONTROL
EJECT
SKIP1
SKIP2
SKIP3
TITLE

+----------------------------End of IBM Extension----------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]