COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 77 ALTER Statement
PROCEDURE DIVISION.
ROUTINE-1.
GO TO INITIALIZATION-ROUTINE.
INITIALIZATION-ROUTINE.
...
ALTER ROUTINE-1 TO PROCEED TO ROUTINE-2.
GO TO ROUTINE-2.
ROUTINE-2.
...
Example 78 Alternative to ALTER Statement
DATA DIVISION.
WORKING-STORAGE SECTION.
77 FLAG VALUE IS 1.
PROCEDURE DIVISION.
ROUTINE-1.
GO TO INITIALIZATION-ROUTINE
ROUTINE-2
DEPENDING ON FLAG.
INITIALIZATION-ROUTINE.
...
MOVE 2 TO FLAG.
GO TO ROUTINE-2.
ROUTINE-2.
...
paragraph-name in an Independent Segment
If paragraph-name is in an independent segment (a section whose segment-number is
greater than 49), these restrictions apply:
Every ALTER statement that references the paragraph-name must be in a section that
has the same segment-number as the section containing paragraph-name.
If the destination is in a section that does not have the same segment-number as the
section containing paragraph-name, these restrictions apply:
An ALTER statement in the Declaratives Portion cannot refer to a paragraph-name
or destination in the other portion of the Procedure Division.
An ALTER statement cannot be used to establish a potential transfer of control between
the Declaratives Portion and the other portion of the Procedure Division.
An ALTER statement cannot refer to a paragraph-name or destination in any
debugging declarative procedure unless the ALTER statement itself is in a debugging
declarative procedure.
An ALTER statement cannot be used to establish a potential transfer of control between
a debugging declarative procedure and a nondebugging declarative procedure.
Canceling the Effects of ALTER Statements
The effect of an ALTER statement persists until the execution of either:
Another ALTER statement with the same destination
A CANCEL statement in which program-name is the program containing the paragraph
in which destination appears.
292 Procedure Division Verbs