Difference between CRTPGM command and CRTBNDRPG

695 pts.
AS/400 Control Language
RPG Program
Hi, Can any one please tell me what is the difference between CRTPGM command and CRTBNDRPG command and what is the appropriate use of these commands ?

Answer Wiki

Thanks. We'll let you know when a new response is added.

CRTRPGMOD – compiles an RPGLE or SQLRPGLE source creating a module
CRTPGM – packages one or more modules into a program

CRTBNDRPG – combines CRTRPGMOD and CRTPGM for simple one module per program cases.
Use this when you can (it is option 14 on PDM).



CRTBNDRPG – combines CRTRPGMOD and CRTPGM for simple one module per program cases.
Use this when you can (it is option 14 on PDM).

CRTPGM is used to create an executable program from diverse program modules (modules can be from other programming languages, not just RPG). CRTBNDRPG is used to create a standalone executable RPG program. +

Martin Gilbert.

Discuss This Question: 7  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Rjrohwer
    Use CRTPGM if you are compiling a program that uses Modules. Modules are like sub routines but are written out side of the main program. Modules are in a sense a separate program that can accomplish a single task by receiving a piece of information, calculating it and returning a piece of information to the main program. Writing a Module is handy when you have a piece of code that will be needed in several different applications. Instead of having to clog up your main program with a the same piece of code over and over you can write a mod program. The input/output for your mod is coded in the D specs. Think of them as parm's. Here is an example of a written mod that returns a 10 position MM/DD/YYYY date from a Julian Date. H NOMAIN ********************************************************************** *Prototypes ********************************************************************** D #Date10 PR 10 D JulDate 7 0 value ********************************************************************** * (Date10) Return the MM/DD/YYYY value of 7 Digit Julian Date ********************************************************************** P #Date10 B export D #Date10 PI 10 D JulDate 7 0 value D Date10Pos S 10 D Julian5 S 5 0 D MDYDate S D Datfmt(*USA) C Move JulDate Julian5 C *Jul Move Julian5 MDYDate C Move MDYDate Date10Pos C Return Date10Pos P #Date10 E Then in the ILE Program the D Specs and the C Specs to use the mod look like. D #Date10 PR 10 D JulDate 7 0 value ** TermDate is a 7,0 position Julian Date, TUTERM will be the result of the #DATE10 line returning a MM/DD/YYYY value C If TermDate = *Zero C Eval TUTERM = *Blanks C Else C Eval TUTERM = #DATE10(TermDate) C Endif The CRTPGM for compiling the main program with the mod would look something like this. It tells the system what the name of the programs are that to be compiled together as one. If you have a mod in your program but don't list it on the CRTPGM the compile will fail. Program . . . . . . . . . . . . TM010LB Name Library . . . . . . . . . . . TESTLIB Name, *CURLIB Module . . . . . . . . . . . . . TM010LB Name, generic*, *PGM, *ALL Library . . . . . . . . . . . TESTLIB Name, *LIBL, *CURLIB... + for more values M.DATE10 TESTLIB Text 'description' . . . . . . . *ENTMODTXT So the short story is if you are not writing programs with Modulars you should not need to use CRTPGM.
    25 pointsBadges:
  • Cwc
    The use of modules, particularly through service programs, is encouraged because it faciliates code reusability and faster development in the future. Modules can be thought of as basic building blocks for applications. The old model of creating long monolithic programs that are harder to maintain and troubleshoot is obsolete. Smaller components of code which have a specific purpose and use local variables are ultimately easier to to troubleshoot. Once you know that they work, they wouldn't have to be touched again unless their logic or parameter interfaces need to be tweaked, or if you just wanted to know how their logic works. Familiarization with this makes it easier too, to cross over into object oriented programming, such as Java and .Net.
    4,290 pointsBadges:
  • Worktoplay
    One of the best parts of creating a module then binding it into a program allows you to debug the program without the need for source. I support a set of programs used in several locations. Creating the module using *LIST for DBGVIEW and then binding the module into a program, I can debug the program at any location without the need for the source. This is a lifesaver for what I do.
    35 pointsBadges:
  • TomLiotta
    Also note that CRTBNDRPG can bind multiple modules into a *PGM. It just requires the use of BNDDIR() either on the command or in an H-spec in the main module that is being compiled. Tom
    125,585 pointsBadges:
  • pkay101
    write a program that will convert american currencies and return the coverted amount. the program should accept two parameters, the amount and the currency to be converted. this application will allow the user to enter the amount and the currency abbreviation. 
    10 pointsBadges:
  • anandx
    Attaching another module to a main pgm can be done only at crtpgm stage not at crtrpgmod stage. 
    Let's say X1 is a main module and Y and Z are two separate modules. Y and Z can be attached to X1 at CRTPGM stage. This has a drawback. Let's say X2 is another main module which also attaches Y and Z. When Y is changed, then both X1 and X2 pgms have to be recompiled. 
    On the other hand, if Y and Z are created as separate *srvpgm, then when Y is changed (other than the proto parms), X1 and X2 need not be recompiled.
    CRTRPGMOD and then CRTPGM allows both those two methods. CRTBNDRPG does not allow the first method (former). In that respect it is a standalone single module. But, it can still call another (static bind proc call) module, but it should be inside the code and if the called module is a *srvpgm. 
    In order do so it needs a *bnddir which cannot be done from command line as CRTBNDRPG does not give *bnddir parameter. Again, this can be done only by including in the source code as ctl-opt (H spec)

    765 pointsBadges:
  • TheRealRaven
    @anandx :  "CRTBNDRPG does not allow the first method..."

    Yes, it does, by using a binding directory and the BNDDIR() control option. The BNDDIR() command parameter is not needed for CRTBNDRPG.

    You final statement contradicts your earlier ones since it seems to say that it can be done.
    32,480 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: