All a binding directory does is to provide a list of bindable modules and service programs that can be used by the HLL compiler. This list means that you do not have to specify each module or service program a program will use on the CRTPGM command, or in the H-specs of an ILE program source. A PROGRAM, in this case, is a piece of RPG source which does NOT specify *NOMAIN, so it has a mainline and a single entry point and a proper exit. A MODULE is a piece of source that has *NOMAIN specified, and has exported procedures which return control using the RETURN operation code.
So you create a program that uses other modules (and perhaps service programs), and when you create the program you want those modules and service programs to be found and bound to it. To do that, you can specify each module on the MODULE parameter of the CRTPGM command, and each service program on the BNDSRVPGM parameter, and specify which module is the entry procedure module. In RPG, only modules which did NOT specify *NOMAIN can be specified here, and usually that module is the one which has the same name as the program.
What happens if you specify modules or service programs that are not used by the entry procedure module, or by modules which are used by it? Well, they are not bound, because the procedure calls are checked and linked to the exports of the modules. If no exports are used from a particular module or service program, that module or service program is not linked.
Now if you specify a binding directory instead of the list of specific modules and service programs, your CRTPGM command gets a lot simpler, so you can use a binding directory just as a list of all the USEFUL sets of procedures you have. Anything that is NOT used is not bound.
There is really no need to have more than one binding directory, especially if all the objects in it have a library entry of *LIBL. Of course, there are times when it may be useful to have a specialized binding directory, but within a single set of application programs. I have not found a case for more than two binding directories to be created.
In your case, though, you seem to use binding directories as if they were specific to each program. This makes it very difficult for you to maintain anything, since the name of the binding directory is not kept as part of the program object.
You could specify the binding directory name in the source of the program entry procedure module (H-spec BNDDIR keyword). This at least means you can find it easily. But as it is, you will have to work with all your binding directories and display their entries until you find the one you want.
This was first published in September 2005