Calling Entry Points in Subprograms

You can execute called programs from a specified entry point, rather than the start of the Procedure Division. You define entry points in programs that you call, using the ENTRY statement. You can then execute a called program starting at an entry point by specifying the entry point in the CALL statement.

When a program containing entry points is loaded into the run-time system, all the entry points in the program are identified to the run-time system and are available to be called by any program that is loaded later.

However, the run-time system cannot locate entry points in programs that are not already loaded. For example, when you execute a CALL statement like this:

CALL "abc" USING ...

the run-time system first looks for a program or entry point called abc in all of the programs that have already been loaded. If the run-time system does not find one, it then looks for a file on disk called abc.ext where .ext is an executable file format. If abc is the name of an entry point in an unloaded program, the run-time system cannot find it.

Therefore, before calling an entry point, either the entry point must be preloaded, or the program containing the entry point must be loaded.

You can preload entry points by creating a library file that contains any programs with entry points. When you call a library file, the run-time system does not load every program in the library file. Instead, the run-time system registers, for future reference, the existence of all programs and entry points contained in the called library file. Later when one of these programs is called, the run-time system notes that it is contained in the library file and loads it at that point.

Note: Entry points must have names that the system assembler and linker can accept; that is, they must contain only characters that are 0-9, A-Z, a-z, underscore, or hyphen.

Entry points are visible only when an assembly has been loaded. There are two solutions for this: