COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
The COPY statement directs the compiler to include additional source text at that point in the
program.
The REPLACE statement directs the compiler to replace source program text.
The USE statement directs the compiler to include logic in the object program that calls the
designated declarative section if the condition described in the USE statement arises during
execution.
Example 61 Compiler-Directing Statement
COPY NEIGHBORS-ANSWER
Scope of Statements
When the formation rules for one statement cause it to contain other statements, you must show
the compiler the scope of both the contained and the containing statements by using scope
terminators. Scope terminators either explicit or implicit.
Explicit scope terminators are defined and listed under Delimited-Scope Statement.
Implicit scope terminators occur at the end of a sentence and at the end of a contained statement.
• At the end of any sentence, the separator period that terminates the scope of all previous
statements not yet terminated is an implicit terminator.
• Within any statement containing another statement, the next phrase of the containing statement
following the contained statement is the implicit terminator of the scope of any unterminated
contained statement.
The detailed rules for scope termination are:
• A conditional statement is composed of other statements. When no delimited-scope statements
occur in the conditional statement, the next phrase of the conditional statement terminates the
contained statement. In this example, the ELSE phrase implicitly terminates the statement of
the THEN phrase and the separator period implicitly terminates the ELSE phrase:
IF CREDIT
THEN PERFORM POST-CREDIT
ELSE PERFORM POST-DEBIT.
• When the last statement in a sentence is a conditional statement, the period separator that
terminates the sentence implicitly terminates the conditional statement. In this example, the
paragraph BOTTOM-LINE consists of a single sentence. The period separator that ends the
sentence ends the IF statement:
BOTTOM-LINE.
MOVE NET-SALES TO NET-S OF SALES-REC-DISPLAY
MOVE NET-PROFIT TO NET-P OF SALES-REC-DISPLAY
IF NET-PROFIT < 0
DISPLAY "Get Cracking!" UPON DIST-MGR-TUBE.
• When statements are contained within other statements, a period separator that terminates
the sentence also implicitly terminates the scope of any contained statements not yet terminated
otherwise. In this example, the period separator terminates both the READ and the IF statements:
IF AUXILIARY-INPUT-TAPE
READ AUX-TAPE
AT END PERFORM AUX-TAPE-ENDED
NOT AT END PERFORM PROCESS-AUX-REC.
• A conditional statement can be nested within an IF statement, but not within any other form
of conditional statement. The preceding example shows a conditional READ statement nested
within an IF statement. It is not possible, for example, to have a READ statement with an AT
END phrase and no END-READ terminator (making it a conditional statement) within another
Procedure Division Components and Syntax 233










