Creating a Program in Two Steps

To take advantage of the flexibility that ILE C/C++ offers, you can compile and bind source code into an ILE C/C++ program in two steps:
  1. In the first step, you create one or more ILE C/C++ module objects (*MODULE) from their respective source members using the Create Module command.
  2. In the second step, you use the Create Program (CRTPGM) command to bind one or more of these module objects into an executable ILE program object (*PGM). Binding is the process of combining one or multiple modules and optional service programs, and resolving external symbols between them. The system code that combines modules and resolves symbols is called the binder.
For example,
    CRTCMOD HELLO 
    CRTPGM HELLO
    CALL HELLO 
Using modules has these advantages:
  • Modules are easier to maintain. It is easier to maintain a small module representing a single function than to maintain an entire program. For example, if you change only a line or two in a module, you may only need to recompile the module, rather than the entire program.
  • Modules are easier to test. Testing of functions can be done in isolation. You do not have to run the entire program. A test harness which includes the module under test can be used instead.
  • Modules are easier to code. You can subdivide the work into smaller source members rather than coding an entire program in a single source file.
  • Modules can be reused in different application programs.