COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-161
Unconditional PERFORM
Placement of Procedures
As a general rule, both proc-1 and proc-2 must be in the same logically
discrete area of the Procedure Division (in a specific declarative procedure,
including any associated sections, or in the portion of the Procedure Division that
does not include declaratives). Most violations of this rule cause the compiler to
issue a warning but to accept the PERFORM statement; however, if either proc-1
or proc-2 is in the Declaratives Portion, then both must be in the Declaratives
Portion.
Placement of PERFORM Statements
As a general rule, a PERFORM statement must be in the same logically discrete
area of the Procedure Division as proc-1 and proc-2. Most violations of this
rule cause the compiler to issue a warning; however, certain combinations are
explicitly permitted, and others are totally prohibited:
°
For any PERFORM statement, proc-1 and proc-2 can be in any
nondebugging declarative procedure; however, the compiler issues a warning if
proc-1 and proc-2 are in two different declarative procedures.
°
When the PERFORM statement is in a debugging declarative procedure, its
proc-1 and proc-2 can be in any declarative procedure; however, the
compiler issues a warning if proc-1 and proc-2 are in two different
declarative procedures.
°
When the PERFORM statement is not in a debugging declarative procedure,
neither proc-1 nor proc-2 can be in any debugging declarative procedure.
°
When the PERFORM statement is in the Declaratives Portion, neither proc-1
nor proc-2 can be in the other portion of the Procedure Division.
Example 9-49. Unconditional PERFORM Statement With One Paragraph
IF REPORT-A
PERFORM DO-REPORT-A
END-IF
Example 9-50. Unconditional PERFORM Statement With Several Paragraphs
IF REPORTS-TO-DO
PERFORM DO-REPORTS THRU DO-REPORTS-EXIT.
IF MUST-EXIT
...
DO-REPORTS.
...
(several paragraphs to create the reports)
...
DO-REPORTS-EXIT.
EXIT.