Modernization Hub

END - Termination statement

Enhanced Definition

In the mainframe context, `END` is a control statement or keyword used to mark the logical or physical termination of a program, a block of code, a data stream, or a sequence of commands within various mainframe languages, utilities, and control languages. Its primary purpose is to signal to the system, compiler, or interpreter that processing for a specific entity is complete. In the mainframe context, `END` (or its variations like `END PROGRAM`, `PEND`, `/*`) serves as a crucial termination statement, signaling the logical end of a program, a JCL procedure, a data stream, or a control statement block. It is a syntactic element that defines boundaries within source code, job control language, or utility input, essential for compilers, assemblers, and JCL interpreters.

Key Characteristics

    • Context-Dependent Syntax: The exact syntax and interpretation of END vary significantly based on the language (COBOL, Assembler, PL/I), utility (IDCAMS, DFSORT), or control mechanism (CICS macro definitions) in which it is used.
    • Compiler/Assembler Directive: For compilers and assemblers, END serves as a directive indicating the absolute end of the source program, prompting the compiler to finalize object code generation and perform any remaining checks.
    • Scope Terminator: In structured programming languages like COBOL, END can be part of explicit scope terminators (e.g., END-IF, END-PERFORM, END-EVALUATE) that define the boundaries of control structures.
    • Utility Command Terminator: Many mainframe utilities use END within their SYSIN stream to signal the completion of a series of utility-specific commands.
    • Logical vs. Runtime Termination: It primarily marks the end of *source code* or *command input*, distinct from runtime statements (like STOP RUN in COBOL or BR in Assembler) that cause a program to terminate execution and return control.

Use Cases

    • COBOL Program Source Termination: The END PROGRAM statement is the final statement in a COBOL source file, indicating the end of the program's definition to the COBOL compiler.
    cobol
    ...
    STOP RUN.
    END PROGRAM MYPROG.
    • Assembler Program Source Termination: In Assembler, the END statement marks the physical end of the source program and can optionally specify the program's entry point.
    assembly
    MYPROG   CSECT
    ...
    BR    R14
    END   MYPROG
    • IDCAMS Utility Command Termination: Used within a JCL SYSIN data stream to terminate a sequence of IDCAMS commands, signaling that no more commands follow.
    jcl
    //SYSIN    DD *
    DEFINE CLUSTER (NAME(MY.VSAM.KSDS) -
    VOLUMES(VSAM01) -
    RECORDS(100 10))
    LISTCAT ENTRIES(MY.VSAM.KSDS) ALL
    END
    /*
    • DFSORT Control Statement Termination: Similar to IDCAMS, END can be used to terminate a block of DFSORT control statements provided in the SYSIN or SORTCNTL DD statement.
    • CICS Macro Definitions: In older CICS macro-level programming or resource definition macros, END might be used to signify the end of a resource definition block.

Related Concepts

The END statement is crucial for the compilation and assembly process, working hand-in-hand with language compilers and assemblers. It complements runtime termination statements such as COBOL's STOP RUN or GO BACK, and Assembler's BR instruction, which handle the actual exit from an executing program and return control to the calling program or the operating system. In JCL, while END isn't typically used to terminate a JOB or EXEC statement, it is frequently embedded within SYSIN streams for utilities, defining the scope of their control input.

Best Practices:
  • Consistent Use in Source Code: Always include the appropriate END statement (e.g., END PROGRAM for COBOL, END with entry point for Assembler) as the final line of your source code to ensure proper compilation and linkage.
  • Explicit Scope Terminators (COBOL): In COBOL, consistently use explicit scope terminators like END-IF, END-PERFORM, `END-EVAL

Related Vendors

Applied Software

7 products

Trax Softworks

3 products

Related Categories

Encryption

41 products

Files and Datasets

168 products

Browse and Edit

64 products