Binding Modules into a Program
In addition to binding modules together, you can also bind them to service pro-
grams (type *SRVPGM). Service programs allow you to code and maintain modules
separately from the program modules. Common routines can be created as service
programs and if the routine changes, the change can be incorporated by binding
the service program again. The programs that use these common routines do not
have to be recreated. For information on creating service programs see Chapter 8,
“Creating a Service Program” on page 91.
For information on the binding process and the binder, refer to the
ILE Concepts
.
Using the CRTPGM Command
The Create Program (CRTPGM) command creates a program object from one or
more previously created modules and, if required, one or more service programs.
You can bind modules created by any of the ILE Create Module commands,
CRTRPGMOD, CRTCMOD, CRTCBLMOD, or CRTCLMOD.
Note: The modules and/or service programs required must have been created
prior to using the CRTPGM command.
Before you create a program object using the CRTPGM command, you should:
1. Establish a program name.
2. Identify the module or modules, and if required, service programs you want to
bind into a program object.
3. Identify the entry module.
You indicate which module contains the program entry procedure through the
ENTMOD parameter of CRTPGM. The default is ENTMOD(*FIRST), meaning
that the module containing the first program entry procedure found in the list for
the MODULE parameter is the entry module.
Assuming you have only one module with a main procedure, that is, all
modules but one have NOMAIN specified, you can accept the default (*FIRST).
Alternatively, you can specify (*ONLY); this will provide a check that in fact only
one module has a main procedure. For example, in both of the following situ-
ations you could specify ENTMOD(*ONLY).
You bind an RPG module to a C module without a main() function.
You bind two RPG modules, where one has NOMAIN on the control spec-
ification.
Note: If you are binding more than one ILE RPG module with a main proce-
dure, then you should specify the name of the module that you want to
receive control when the program is called. You can also specify
*FIRST if the module with a main procedure precedes any other
modules with main procedures on the list specified for the MODULE
parameter.
4. Identify the activation group that the program is to use.
Specify the named activation group QILE if your program has no special
requirements or if you are not sure which group to use. In general, it is a good
idea to run an application in its own activation group. Therefore, you may want
to name the activation group after the application.
Note that the default activation group for CRTPGM is *NEW. This means that
your program will run in its own activation group, and the activation group will
82 ILE RPG for AS/400 Programmer's Guide