# 7.6 END Statement

The END statement marks the end of a program unit. It takes one of the following forms:

  END [PROGRAM [program-name]]
  END [FUNCTION [function-name]]
  END [SUBROUTINE [subroutine-name]]
  END [MODULE [module-name]]
  END [BLOCK DATA [block-data-name]]

For internal procedures and module procedures, you must specify the FUNCTION and SUBROUTINE keywords in the END statement; otherwise, the keywords are optional.

In main programs, function subprograms, and subroutine subprograms, END statements are executable and can be branch target statements. If control reaches the END statement in these program units, the following occurs:

- In a main program, execution of the program terminates.
- In a function or subroutine subprogram, a RETURN statement is implicitly executed.

The END statement cannot be continued in a program unit, and no other statement in the program unit can have an initial line that appears to be the program unit END statement.

The END statements in a module or block data program unit are nonexecutable.

For More Information:

- On program units and procedures, see Chapter 8.
- On branch target statements, see Section 7.1.

Previous Page Next Page Table of Contents