A COBOL subroutine is a source file that contains COBOL code and implements a logical function. It is organized so that other programs can prepare the appropriate information, call the subroutine, and perform the function. Subroutine parameters are described in the LINKAGE SECTION of the subroutine. The subroutine is able to evaluate or modify passed parameters as part of its algorithm.
The calling program uses a subroutine when it defines and prepares the parameter items for the subroutine, and then calls it. The parameters are passed to the subroutine, using the CALL SUBROUTINE USING statement. After the subroutine completes its function, the calling program can examine the parameter items to see the information returned by the subroutine.
JAVA vs COBOL
Class: A subroutine is similar to a class. It can perform certain functions when called. The subroutine developer defines these functions. Many calling programs can use this subroutine in order to perform those functions.
Interface: The signature, or parameter specification, for a particular subroutine (or class, in OO terms). In COBOL, a subroutine’s signature is the list of items in the subroutine’s LINKAGE SECTION. Some items in an interface may be input parameters, and some may be result parameters, or both.
Object: An instance of a class, similar to an instance of the COBOL subroutine’s CONTROL area, after the subroutine has been called. You can think of an object as the result of initializing the subroutine or calling it for the first time. This result is stored in the subroutine’s CONTROL area.
Class data members: The data items that are associated with the subroutine (or class). Class data members include both the data elements in the subroutine’s LINKAGE SECTION and the data elements in the subroutine’s WORKING-STORAGE. Class data members are also called properties of the class.
Private: Any data elements (or properties) that belong to the class but are not available outside the class. In COBOL, the items in a subroutine’s WORKING-STORAGE area are private.
Public: Any data elements (or properties) that belong to the class but are available outside the class. They are similar to items in a COBOL subroutine’s LINKAGE SECTION.