PERFORM
is used to execute a paragraph located somewhere in the program and then, once executed, the execution flow will continue on
the line following the PERFORM statement. This is the expected behaviour that can be broken if a GO TO
is added in the called paragraph.
When mixing PERFORM
and GO TO
you can quickly be lost on the execution flow and finally don’t get the one you expect. For
this reason, calling PERFORM
with paragraphs that used GO TO
should be avoided.
Noncompliant code example
PROCEDURE DIVISION.
DISPLAY-9-LETTERS.
PERFORM ABC.
DISPLAY "END OF DISPLAY-9-LETTERS".
STOP RUN.
ABC.
DISPLAY "ABC".
GO TO XYZ.
DEF.
DISPLAY "DEF".
XYZ.
DISPLAY "XYZ".
Compliant solution
PROCEDURE DIVISION.
DISPLAY-9-LETTERS.
PERFORM ABC.
PERFORM DEF.
PERFORM XYZ.
DISPLAY "END OF DISPLAY-9-LETTERS".
STOP RUN.
ABC.
DISPLAY "ABC".
DEF.
DISPLAY "DEF".
XYZ.
DISPLAY "XYZ".