Skip to main content

This article explains why an RTS 166 Error occurs when COBOL CALL an ENTRY point that is defined in the main source file.

Problem:

The main source file pmain.cbl is as follows:

PROGRAM-ID. PMAIN.
PROCEDURE DIVISION.
CALL “sp01”.
STOP RUN.
ENTRY “sp02”.
EXIT PROGRAM.

The called source file sp01.cbl is as follows:

PROGRAM-ID. SP01.
PROCEDURE DIVISION.
CALL “sp02”.

If the application runs in Intermediate Code, or if the compiler directive RECURSECHECK is used to generate ( -N RECURSECHECK ), the error 166 is displayed.

Resolution:

In fact , if you want to have a recursive environment , you can down this as follows and compile again:

PROGRAM-ID. PMAIN IS RECURSIVE .

Or

PROGRAM-ID. PMAIN.

LOCAL-STORAGE SECTION.

PROCEDURE DIVISION.

However , be aware of the initial status of all data involved in that case at run time , refer to Program Development documentation Chapter 3.

Old KB# 14924