Inspecting the PCB status code and related information using the com.ibm.ims.dli.AIB interface

To inspect the PCB status code, return code, reason code, error code extension, and related information after a data access call by the IMS Universal drivers, use the com.ibm.ims.dli.AIB interface provided by the IMS Universal DL/I driver.

Typically, the IMS Universal drivers throws an exception if a call is not successful. The non-blank status codes that do not generate an exception are GD, GE, GB, GA, GK, QC, QD, and CF. In error cases, the generated exception contains the most pertinent information such as PCB status code, return code, reason code, and error code extension. To inspect the PCB status code and related information for all the non-error cases, use the com.ibm.ims.dli.AIB interface.

The AIB instance contains all the data attributes of an IMS application interface block. The AIB instance also contains a reference to a com.ibm.ims.dli.DBPCB instance, which contains all the data attributes of a PCB instance.

When your IMS Universal drivers application makes a data access call to IMS, the application is internally making a DL/I call using a com.ibm.ims.dli.PCB instance. After each DL/I call that your application issues, IMS places a two-character status code in the DBPCB instance stored in the AIB instance for that PCB instance.

The com.ibm.ims.dli.IMSStatusCodes class contains constants for the IMS status codes. Use this helper class for comparison checking of the status code from the DL/I call.

The following code example shows how to access the AIB instance from a IMS Universal DL/I driver application:
try {
   psb = PSBFactory.createPSB(connSpec);
} catch (DLIException e) {
   AIB aib = e.getAib();
   if (aib != null) {
      String sc = aib.getDBPCB().getStatusCodeChars();
      String retcode = aib.getReturnCodeHex();
      String reascode = aib.getReasonCodeHex();
      System.out.println("Status code: " + sc + " Return Code: " 
         + retcode + " Reason Code: " + reascode);
      }
}
The following code example shows how to access the AIB instance from a JDBC application. Note that you need to import the com.ibm.ims.dli package to use the AIB and DLIException objects in your Java™ code.
try {
   resultSet.updateString(1, "Harry Houdini");
} catch (SQLException e) {
   Throwable t = e.getCause();
   if (t != null && t instanceof DLIException) {
      com.ibm.ims.dli.DLIException de = (com.ibm.ims.dli.DLIException) t;
      com.ibm.ims.dli.AIB aib = de.getAib();
      if (aib != null) {
         String sc = aib.getDBPCB().getStatusCodeChars();
         String retcode = aib.getReturnCodeHex();
         String reascode = aib.getReasonCodeHex();
         System.out.println("Status code: " + sc + " Return Code: " 
            + retcode + " Reason Code: " + reascode);
      }
    }
}