Using the CRTBNDRPG Command - IBM - RPG

The Create Bound RPG (CRTBNDRPG) command creates a program object from RPG IV source in one step. It also allows you to bind in other modules or service programs using a binding directory.

The command starts the ILE RPG compiler and creates a temporary module object in the library QTEMP. It then binds it into a program object of type *PGM. Once the program object is created, the temporary module used to create the program is deleted.

The CRTBNDRPG command is useful when you want to create a program object from standalone source code (code that does not require modules to be bound together), because it combines the steps of creating and binding. Furthermore, it allows you to create an OPM-compatible program.

Note: If you want to keep the module object in order to bind it with other modules into aprogram object, you must create the module using the CRTRPGMOD command. For more information see “Creating a Program with the CRTRPGMOD and CRTPGM Commands”.

You can use the CRTBNDRPG command interactively, in batch, or from a Command Language (CL) program. If you are using the command interactively and require prompting, type CRTBNDRPG and press F4 (Prompt). If you need help, type CRTBNDRPG and press F1 (Help).

Table summarizes the parameters of the CRTBNDRPG command and shows their default values.

CRTBNDRPG Parameters and Their Default Values Grouped by Function

CRTBNDRPG Parameters and Their Default Values Grouped by Function

Creating a Program for Source Debugging

In this example you create the program EMPRPT so that you can debug it using the source debugger. The DBGVIEW parameter on either CRTBNDRPG or CRTRPGMOD determines what type of debug data is created during compilation. The parameter provides six options which allow you to select which view(s) you want:

  • *STMT — allows you to display variables and set breakpoints at statement locations using a compiler listing. No source is displayed with this view.
  • *SOURCE — creates a view identical to your input source.
  • *COPY — creates a source view and a view containing the source of any /COPY members.
  • *LIST — creates a view similar to the compiler listing.
  • *ALL — creates all of the above views.
  • *NONE — no debug data is created.

The source for EMPRPT is shown below.

  1. To create the object type:
  2. CRTBNDRPG PGM(MYLIB/EMPRPT) DBGVIEW(*SOURCE) DFTACTGRP(*NO)

    The program will be created in the library MYLIB with the same name as the source member on which it is based, namely, EMPRPT. Note that by default, it will run in the default named activation group, QILE. This program object can be debugged using a source view.

  3. To debug the program type: STRDBG EMPRPT shows the screen which appears after entering the above command.

Display Module Source display for EMPRPT
Display Module Source display for EMPRPT

From this screen (the Display Module Source display) you can enter debug commands to display or change field values and set breakpoints to control program flow while debugging.

Creating a Program with Static Binding

In this example you create a program COMPUTE using CRTBNDRPG to which you bind a service program at program-creation time.

Assume that you want to bind the program COMPUTE to services which you have purchased to perform advanced mathematical computations. The binding directory to which you must bind your source is called MATH. This directory contains the name of a service program that contains the various procedures that make up the services.

To create the object,type:

The source will be bound to the service program specified in the binding directory MATH atprogram-creation time. This means that calls to the procedures in the service program will take less time than if they were dynamic calls.

When the program is called, it will run in the named activation group GRP1. The default value ACTGRP parameter on CRTBNDRPG is QILE. However, it is recommended that you run your application as a unique group to ensure that the associated resources are fully protected.

Note: DFTACTGRP must be set to *NO in order for you to enter a value for the ACTGRP and BNDDIR parameters

Creating an OPM-Compatible Program Object

In this example you use the CRTBNDRPG command to create an OPM-compatible program object from the source for the payroll program, shown below.

  1. To create the object, type:
  2. The CRTBNDRPG command creates the program PAYROLL in MYLIB, which will run in the default activation group. By default, a compiler listing is produced.

    Note: The setting of DFTACTGRP(*YES) is what provides the OPM compatibility. This setting also prevents you from entering a value for the ACTGRP and BNDDIR parameters. Furthermore, if the source contains any bound procedure calls, an error is issued and the compilation ends.

  3. Type one of the following CL commands to see the listing that is created:
    • DSPJOB and then select option 4 (Display spooled files)
    • WRKJOB
    • WRKOUTQ queue-name
    • WRKSPLF

A Sample Payroll Calculation Program

A Sample Payroll Calculation Program


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM - RPG Topics