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:
- Establish a program name.
- Identify the module or modules, and if required, service programs you
want to bind into a program object.
- 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 situations 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 specification.
Note: If you are binding more than one ILE RPG module with
a main procedure, 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.
- 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 terminate when the program does. Whether
or not you set on LR, your program will have a fresh copy of its data the
next time you call it. For more information on activation groups see Specifying an Activation Group.
To create a program object using the CRTPGM command, perform the following
steps:
- Enter the CRTPGM command.
- Enter the appropriate values for the command parameter.
Table 1 lists the CRTPGM command parameters
and their default values. For a full description of
the CRTPGM command and its parameters, refer to the CL
and APIs section of the Programming category
in the IBM® i
Information Center at this Web site - http://www.ibm.com/systems/i/infocenter/.
Table 1. Parameters for CRTPGM Command and their
Default Values| Parameter Group |
Parameter(Default Value) |
| Identification |
PGM(library name/program name)
MODULE(*PGM)
|
| Program access |
ENTMOD(*FIRST) |
| Binding |
BNDSRVPGM(*NONE)
BNDDIR(*NONE)
|
| Run time |
ACTGRP(*NEW) |
| Miscellaneous |
OPTION(*GEN *NODUPPROC *NODUPVAR *WARN *RSLVREF)
DETAIL(*NONE)
ALWUPD(*YES)
ALWRINZ(*NO)
REPLACE(*YES)
AUT(*LIBCRTAUT)
TEXT(*ENTMODTXT)
TGTRLS(*CURRENT)
USRPRF(*USER)
|
Once you have entered the CRTPGM command, the system performs the following
actions:
- Copies listed modules into what will become the program object, and links
any service programs to the program object.
- Identifies the module containing the program entry procedure, and locates
the first import in this module.
- Checks the modules in the order in which they are listed, and matches
the first import with a module export.
- Returns to the first module, and locates the next import.
- Resolves all imports in the first module.
- Continues to the next module, and resolves all imports.
- Resolves all imports in each subsequent module until all of the imports
have been resolved.
- If any imports cannot be resolved with an export, the binding process
terminates without creating a program object.
- Once all the imports have been resolved, the binding process completes
and the program object is created.
Note: If you have specified that a variable or procedure is
to be exported (using the EXPORT keyword), it is possible that the variable
or procedure name will be identical to a variable or procedure in another
procedure within the bound program object. In this case, the results may not
be as expected. See ILE Concepts for information on how to handle
this situation.