PROCEDURE statement

A PROCEDURE statement identifies the procedure as a main procedure, a subroutine, or a function. Parameters expected by the procedure and other characteristics are also specified on the PROCEDURE statement.

Read syntax diagramSkip visual syntax diagramentry-label:PROCEDURE(,parameter)returns-optionOPTIONS( options)RECURSIVEORDERREORDEREXTERNAL ( environment-name)scope-attribute;statementgroupinternal-procedurebegin-blockENDentry-label ;

Abbreviations: PROC for PROCEDURE

entry-label
The entry point to the procedure. External entries are explicitly declared in the invoking procedure. If multiple entry labels are specified, the leftmost name is the primary entry point and is the name returned by the PROCNAME and ONLOC built-in functions. For more information, see Entry data.
parameter
See Parameter attribute and Passing arguments to procedures.
returns-option
Applies only to function procedures. See Functions and RETURNS option and attribute.
OPTIONS option
See OPTIONS option and attribute.
RECURSIVE
See Recursive procedures.
ORDER or REORDER
ORDER and REORDER are optimization options that are specified for a procedure or begin-block. For more information about using the ORDER and REORDER, see ORDER or REORDER in OPTIONS option and attribute.
EXTERNAL (environment name)
Is a scope attribute discussed in Scope of declarations.
scope-attribute
See Scope of declarations.

A procedure (subroutine or function) can have one or more entry points. The primary entry point to a procedure is established by the leftmost label of the procedure statement. Secondary entry points to a procedure are established by additional labels on the PROCEDURE statement and by the ENTRY statement. Each entry point has an entry name. See INTERNAL and EXTERNAL attributes for a discussion of the rules for the creation of an external name.