GOTO command and labels

The GOTO command processes an unconditional branch.

With the GOTO command, processing is directed to another part (identified by a label) of the procedure whenever the GOTO command is encountered. This branching does not depend on the evaluation of an expression. After the branch to the labeled statement, processing begins at that statement and continues in consecutive sequence; it does not return to the GOTO command unless specifically directed back by another instruction. You can branch forward or backward. You cannot use GOTO to go to a label outside the procedure, nor can you use a GOTO to branch into or out of a subroutine defined within the procedure. The GOTO command has one parameter, which contains the label of the statement branched to:

GOTO CMDLBL(label)

A label identifies the statement in the procedure to which processing is directed by the GOTO command. To use a GOTO command, the command you are branching to must have a label.

          PGM
          .
          .
          .
START:    SNDRCVF RCDFMT(MENU)
          IF (&RESP=1) THEN(CALL CUS210)
          .
          .
          .
          GOTO START
          .
          .
          .
          ENDPGM

The label in this example is START. A label can have as many as 10 characters and must be immediately followed by a colon, but blanks can occur between the label and the command name.

Related information
CL command finder
Go To (GOTO) command