END - Termination statement
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
ENDvary 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,
ENDserves 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,
ENDcan 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
ENDwithin theirSYSINstream 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 RUNin COBOL orBRin Assembler) that cause a program to terminate execution and return control.
- Context-Dependent Syntax: The exact syntax and interpretation of
Use Cases
-
- COBOL Program Source Termination: The
END PROGRAMstatement 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
ENDstatement 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
SYSINdata stream to terminate a sequence ofIDCAMScommands, 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,ENDcan be used to terminate a block ofDFSORTcontrol statements provided in theSYSINorSORTCNTLDD statement. - CICS Macro Definitions: In older CICS macro-level programming or resource definition macros,
ENDmight be used to signify the end of a resource definition block.
- COBOL Program Source Termination: The
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.
- Consistent Use in Source Code: Always include the appropriate
ENDstatement (e.g.,END PROGRAMfor COBOL,ENDwith 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