Application programming on z/OS
Previous topic | Next topic | Contents | Glossary | Contact z/OS | PDF


Source, object, and load modules

Application programming on z/OS

A program can be divided into logical units that perform specific functions. A logical unit of code that performs a function or several related functions is a module. Separate functions should be programmed into separate modules, a process called modular programming. Each module can be written in the symbolic language that best suits the function to be performed.

Each module is assembled or compiled by one of the language translators. The input to a language translator is a source module; the output from a language translator is an object deck. Before an object deck can be executed, it must be processed by the binder (or the linkage editor). The output of the binder is a load module; see Figure 1.

Figure 1. Source, object, and load modules
Source, object, and load modules

Depending on the status of the module, whatever it is–source, object or load–it can be stored in a library. A library is a partitioned data set (PDS) or a partitioned data set extended (PDSE) on direct access storage. PDSs and PDSEs are divided into partitions called members. In a library, each member contains a program or part of a program.

Source programs (or source code) is a set of statements written in a computer language. Source programs, once they are error-free, are stored in a partitioned data set known as a source library. Source libraries contain the source code to be submitted for a compilation process, or to be retrieved for modification by an application programmer.

A copybook is a source library containing pre-written text. It is used to copy text into a source program, at compile time, as a shortcut to avoid having to code the same set of statements over and over again. It is usually a shared library in which programmers store commonly used program segments to be later included into their source programs. It should not be confused with a subroutine or a program. A copybook member is just text; it might not be actual programming language statements.

A subroutine is a commonly-called routine that performs a predefined function. The purpose behind a copybook member and a subroutine are essentially the same, to avoid having to code something that has previously been done. However, a subroutine is a small program (compiled, link-edited and executable) that is called and returns a result, based on the information that it was passed. A copybook member is just text that will be included in a source program on its way to becoming an executable program. The term copybook is a COBOL term, but the same concept is used in most programming languages.

If you use copybooks in the program that you are compiling, you can retrieve them from the source library by supplying a DD statement for SYSLIB or other libraries that you specify in COPY statements. In Figure 2, we insert the text in member INPUTRCD from the library DEPT88.BOBS.COBLIB into the source program that is to be compiled.

Figure 2. Copybook in COBOL source code
//COBOL.SYSLIB  DD  DISP=SHR,DSN=DEPT88.BOBS.COBLIB 
//SYSIN    DD  *
                 IDENTIFICATION DIVISION.
       . . .
       COPY INPUTRCD
       . . .

Libraries must reside on direct access storage devices (DASDs). They cannot be in a hierarchical file system (HFS) when you compile using JCL or under TSO.





Copyright IBM Corporation 1990, 2010