IBM Extension
IBM Extension

RECURSIVE Clause

The RECURSIVE clause is an optional clause that allows COBOL programs to be recursively re-entered. This clause specifies that the program and any program contained within it are recursive. ILE COBOL allows the RECURSIVE clause in a nested program. As well, recursive programs will be able to contain a nested subprogram. Program-name-1 can be recursively re-entered while a previous invocation is still active if the RECURSIVE clause is specified. An active program cannot be recursively re-entered if the RECURSIVE clause is not specified.

The Working-Storage Section of a recursive program defines storage that is statically allocated and initialized on the first entry to a program, and is available in a last-used state to any of the recursive invocations. The Local-Storage Section of a recursive program (as well as a non-recursive program) defines storage that is automatically allocated, initialized, and deallocated on a per-invocation basis.

Internal file connectors corresponding to FDs in the File Section of a recursive program are statically allocated. The status of internal file connectors is part of the last-used state of a program that persists across invocations.

The following language elements are not supported in a recursive program: The RECURSIVE clause shall not be specified if any program that directly or indirectly contains this program is an inital program.
End of IBM Extension
End of IBM Extension