GOTO LABEL command

The GOTO LABEL command causes z/OS® Debugger to resume program execution at the specified statement label. The specified label must be in the same block. If you want z/OS Debugger to return control to you at the target location, make sure there is a breakpoint at that location.

Read syntax diagramSkip visual syntax diagramGOTOGOTOLABELstatement_label'statement_label';
statement_label
A valid statement label within the currently executing program or, in PL/I, a label variable.

Usage notes

  • For COBOL, if a GOTO LABEL command is issued and the specified label contains an EXIT statement, the results might be unpredictable such as an ABEND because the EXIT statement might not be specified with a return location.
  • You can use the GOTO command if the SET WARNING is set to OFF and the runtime level allows GOTO without compiler enablement for the following programs:
    • A COBOL program compiled without hooks being inserted by the compiler and with optimization, if you compiled with the NOEJPD suboptions of the TEST compiler option
    • A program compiled with Enterprise COBOL for z/OS Version 5 or later and optimized by Automatic Binary Optimizer for z/OS
    • A program compiled with Open XL C/C++ for z/OS
    The use of GOTO in this case might cause unpredictable behaviors, including abends, when the GOTO command is executed or followed. You can get the best behavior of GOTO command in programs that are compiled with OPT and TEST(NOEJPD) options in either of the following situations:
    • When the target of the GOTO or JUMPTO command is a paragraph name or a section name (label).
    • When the target of the GOTO or JUMPTO command is the first statement in the paragraph or section.
    You can get the best behavior especially if the statements are targets of COBOL statements PERFORM or GOTO in the COBOL program. See SET WARNING command (C, C++, COBOL, and PL/I).
  • Use the syntax of statement_label enclosed in apostrophes (') only for LangX COBOL programs. It is not supported in any other programming language.
  • In PL/I, out-of-block GOTOs are allowed. However, qualification might be needed.
  • The LABEL keyword is optional when either the target statement_label is nonnumeric or if it is qualified (whether the actual label was nonnumeric or not).
  • A COBOL statement_label can have either of the following forms:
    • name

      This form can be used in COBOL for reference to a section name or for a COBOL paragraph name that is not within a section or is in only one section of the block.

    • name1 OF name2 or name1 IN name2

      This form must be used for any reference to a COBOL paragraph (name1) that is within a section (name2), if the same name also exists in other sections in the same block. You can specify either OF or IN, but z/OS Debugger always uses OF for output.

    Either form can be prefixed with the usual block, compile unit, and load module qualifiers.

  • For C, to be able to use the GOTO LABEL command, you must compile your program in one of the following ways:
    • With either the PATH or ALL suboption and the SYM suboption of the TEST compiler option.
    • With either the PATH or ALL suboption and the SYM suboption of the DEBUG compiler option.
    There are no restrictions on using labels with the GOTO LABEL command.
  • For C++, to be able to use the GOTO LABEL command, you must compile your program in one of the following ways:
    • With the TEST compiler option.
    • With either the PATH or ALL suboption and the SYM suboption of the DEBUG compiler option.
    There are no restrictions on using labels with the GOTO LABEL command.
  • For COBOL programs, you can use GOTO LABEL command if you compile your program with the following suboptions and compilers:
    • The HOOK suboption of the TEST compiler option with Enterprise COBOL for z/OS, Version 4
    • The PATH or ALL suboption and the SYM suboption of the TEST compiler option with the following compilers:
      • Enterprise COBOL for z/OS and OS/390®, Version 3
      • COBOL for OS/390 & VM, Version 2
    • For Enterprise COBOL for z/OS Version 5, programs are always compiled without hooks inserted by the compiler. If you are using the TEST compiler option in combination with any level of the OPT compiler option, it is recommended to use the EJPD suboption of the TEST compiler option.
    The label can take one of the following forms:
    • name, where name is a section name, or the name of a paragraph not within a section or in only one section of the block.
    • name1 OF name2 or name1 IN name2, where name1 is duplicated by one or more other paragraphs in one or more other sections in the block. You can use either OF or IN, but z/OS Debugger always displays OF in the log.
  • For PL/I, you can use GOTO LABEL only if you compiled your program with either the PATH or ALL suboption and the SYM suboption of the TEST compiler option. There are no restrictions on using labels with GOTO LABEL and label variables are supported.
  • GOTO LABEL is not available while debugging Enterprise PL/I programs.
  • You cannot use the GOTO LABEL command while you are replaying recorded steps by using the PLAYBACK commands.
  • You cannot use the GOTO LABEL command while you debug an optimized COBOL program.
  • This command cannot be used if you are stopped at an AT APPEARANCE breakpoint, an AT LOAD breakpoint, or an AT DELETE breakpoint.

Examples

  • Go to the label constant laba in block suba in program prog1.
    GOTO prog1:>suba:>laba;
  • Go to the label constant para OF sect1. The current programming language setting is COBOL.
    GOTO LABEL para OF sect1;

Refer to the following topics for more information related to the material discussed in this topic.

  • Related tasks
  • IBM® z/OS Debugger User's Guide
  • Related references
  • statement_label