IBM i e-Book
A Developer’s Guide to Mastering IBM i Concepts
IBM i Index
Integrated Language Environment
Bind By Copy
Bind by copy is nothing but static binding. Binding a module with "Bind by copy" means entire module object definition is copied into the bounded program. Once you create a program object with module using bind by copy, you can delete the module object, but the program still gets executed.
The modules specified on the MODULE parameter of commands like CRTPGM, CRTSRVPGM etc. are always bound by copy. Refer below screenshots for more info.
Module parameter from CRTSRVPGM
Even if you add modules to a binding directory and bind them to program using binding directory, then it is bind by copy.
Advantages of Bind by Copy
If you bind a module to a program using bind by copy, there will not be any overhead in loading and executing the program. So, the program execution gets faster.
Disadvantages of Bind by copy
If you have simple piece code in module and bind it in multiple programs using bind by copy, each program will have the copy of the code and that increases the program size.
Also, if you need to make any modifications to that piece of code, you need to modify the module and need to recompile all the programs that are bounded the module. In such scenarios, maintaining list of bounded programs is another overhead.
Below is a simple code to print some patterns:
Module 1
CRTRPGMOD MODULE(QTEMP/PATTERN) SRCFILE(DEMOLIB/QRPGLESRC)You can create the program using the command below.
CRTPGM PGM(QTEMP/PATTERN) MODULE(QTEMP/PATTERN)Check the objects using the below command.
WRKOBJ QTEMP/PATTERN
Now delete the module by taking option 4
Now call the program