Thursday, October 27, 2022

View Binding Directory Entries from SQL - IBM i

View Binding Directory Entries

Binding directory is an object that holds the list of modules and/or service programs that may be required for the compilation of ILE programs. 

In other words, Binding directory contains modules and/or service programs whose procedures might be used across different ILE programs and are required for compiling the ILE programs. 

Can these programs be compiled without the use of binding directory? The answer is Yes. If a program is using procedures from one service program (say SRVPGM1), corresponding service program to be added against the parameter BNDSRVPGM when creating the program using CRTPGM. 

So, Why is binding directory needed? In the above scenario, we are only talking about one program using procedure from one service program so it is easy to mention service program name while creating a program. Say if we have many procedures across different service programs (most common), It becomes hard to remember and adding all the service program names while compiling. 

Binding directory provides the option to add all the modules and service programs whose procedures could be used in various programs. And, binding directory name can either be added in the H spec of the RPGLE source or against BNDDIR parameter in the compilation command (CRTPGM, CRTBNDRPG...). 

How do we view the entries in binding directory? Traditionally, DSPBNDDIR (Display Binding Directory) command is used to display the entries in binding directory. 

DSPBNDDIR BNDDIR(<library>/<binding-directory>) 

Same information can now be viewed from the SQL by running a SELECT query on the view BINDING_DIRECTORY_INFO (system name - QSYS2/BNDDIR_INF). 

This view contains the same information as it is displayed using DSPBNDDIR. 
  • BINDING_DIRECTORY_LIBRARY - The library which contains the binding directory.
  • BINDING_DIRECTORY - The binding directory name.
  • ENTRY_LIBRARY - The library containing entry (i.e., service program or module). Can contain the special value *LIBL.
  • ENTRY - The name of the binding directory entry.
  • ENTRY_TYPE - The object type of the binding directory entry. Valid values are *MODULE and *SRVPGM.
  • ENTRY_ACTIVATION - The activation control of the bound service program. Valid values are *DEFER (Activation of the bound service program may be deferred until a function it exports is called) and *IMMED (Activation of the bound service program takes place immediately when the program or service program it is bound to is activated). Contains the null value if ENTRY_TYPE is *MODULE.
  • ENTRY_CREATE_TIMESTAMP - The timestamp when the object was created. Contains the null value if the entry timestamp is not available.
There are two major advantages of using the SQL view (BINDING_DIRECTORY_INFO) over the command DSPBNDDIR. 
  • There is no provision for filter to check for a specific entry in the binding directory in DSPBNDDIR. So one has to page down and find out to see if the specific entry is  present in binding directory. 
  • One has to run command DSPBNDDIR on multiple binding directory to find out all the binding directories in which a specific entry is added. 
Both of these can be easily achieved with the use of SQL view. 

Check for the entries starting with TEST in a specific binding directory. 


Check for the binding directory which has entry TESTSRVPGM and entry library TESTLIB. 


Similarly, we can run the query based on the entry activation, entry create timestamp or any other fields as required.

If you have any Suggestions or Feedback, Please leave a comment below or use Contact Form.

No comments:

Post a Comment

Different Ways of Sorting Data in a List - Python

Sorting Data in a List List is a collection of data (of different data types), much like an array. Like any data structure or data set, dat...