Identifying a program as recursive

Code the RECURSIVE attribute on the PROGRAM-ID clause to specify that a program can be recursively reentered while a previous invocation is still active.

About this task

You can code RECURSIVE only on the outermost program of a compilation unit. Neither nested subprograms nor programs that contain nested subprograms can be recursive. You must code RECURSIVE for programs that you compile with the THREAD option.
Note: A PERFORM statement must not cause itself to be executed. This constitutes a recursive PERFORM, which can cause unpredictable results. Therefore, you must not specify recursive PERFORM statements. See Basic PERFORM statement for details.

Refer to the Example: storage sections, which shows that a recursive program uses both WORKING-STORAGE and LOCAL-STORAGE. Note that a recursive program will have only 1 copy of WORKING-STORAGE, but a new copy of LOCAL-STORAGE for each CALL.