AS/400 Links Partner with Rochester Institute Contact Us
Training Catalog Free Downloads Privacy / Usage

FREE AS/400, iSeries, and System i / iSeries Downloads
HOME >> FREE AS/400, iSeries, and System i / iSeries Downloads >> RPG "Cheat Sheet" #3 - Binding Directories

RPG "Cheat Sheet" #3 - Binding Directories
Author: Craig Pelkie


A binding directory is an OS/400 object (type *BNDDIR). A binding directory contains a list of one or more module (*MODULE) or service program (*SRVPGM) objects that are used when creating other modules, service programs or programs.

Using binding directories may make it easier to create ILE objects. For example, suppose you want to create service program UTILITIES, made up of modules STRING, DATES and UTILITIES.

If you don't use binding directories, you would create the service program like this:

          TEXT('Utiltiies service program')

If you use a binding directory for the list of modules, you could create the service program like this:

          TEXT('Utiltiies service program')

The advantage of using the binding directory is that you don't need to remember and type the list of modules that are used in the service program. When you run the CRTSRVPGM command, it looks into the binding directory for the list of modules.

Create and use binding directories

Step 1 - Use the CRTBNDDIR command to create the binding directory 
Use the Create Binding Directory (CRTBNDDIR) command to create a *BNDDIR object::

      CRTBNDDIR BNDDIR(libname/bnddir_name)

Step 2 - Add entries to the binding directory 

A binding directory entry is a simple or qualified name of a *MODULE or *SRVPGM object. You can add the name of a *MODULE or *SRVPGM to the binding directory before the object exists. 
There are two commands you can use to add an entry to a binding directory:

  • ADDBNDDIRE - Add Binding Directory Entry
  • WRKBNDDIRE - Work with Binding Directory Entries

The ADDBNDDIRE looks like this:

ADDBNDDIRE BNDDIR(libname/bnddir_name)
           OBJ((libname/srvpgm_name *SRVPGM) (libname/module_name *MODULE))

libname can be specified as *LIBL or as an actual library name.

The WRKBNDDIRE command uses an interactive display panel. You can view, remove and add binding directory entries for a binding directory.


  • The ADDBNDDIRE command includes the POSITION parameter, to indicate where the new binding directory entry is to be added, relative to other entries in the binding directory. This parameter is only important if the module or service program name is already in the binding directory (for example, a module of the same name in different libraries).
  • You can add one or more entries to a binding directory using the OBJ parameter of the ADDBNDDIRE command.
  • The module or service program name that you specify on either command is not checked for existence. Because it is not an error to add a binding directory that does not exist, you should carefully check the spelling of the directory entry to be sure that it specifies the intended object.

Step 3 - Use binding directories on create commands and ILE RPG H-specs 
You can specify one or more binding directories in the BNDDIR parameter when using the following commands:

  • CRTPGM - Create Program
  • CRTSRVPGM - Create Service Program
  • CRTRPGMOD - Create RPG Module

You can use binding directories in addition to or instead of the MODULE and BNDSRVPGM parameters on those commands.

You can specify one or more binding directories in an RPG program control specification ("H-spec"). For example, you might specify three binding directories like this:



  • Binding directory names specified on an RPG H-spec are case sensitive, because the names are specified in quotes. Be sure you enter the binding directory names in uppercase.

Usage Notes 

  1. Use the Creation Date and Time columns on the WRKBNDDIRE command display to verify the existence of a module or service program. If the date and time are blank, the object does not exist.
  2. The same object (*MODULE or *SRVPGM) can be included in more than one binding directory. However, it will be much easier to manage your binding directories if you limit an object to being listed in only one directory.
  3. It is an error to have more than one object (*MODULE or *SRVPGM) in a binding directory that exports the same procedure or data. If you get message CPD5D03 when creating a program or service program, you will need to use the *DUPPROC or *DUPVAR creation options to circumvent the duplicate exported symbols error. 

Learn how to create ILE RPG subprocedures, modules, service programs and programs! Order your copy of Subprocedures for RPG Programmers  by Craig Pelkie.