IBM Support

SQL1131N when invoking Micro Focus COBOL stored procedures

Question & Answer


Question

This technote provides troubleshooting methods for when you are executing Micro Focus COBOL stored procedures with DB2 for Linux, Unix, and Windows (DB2 LUW) and receive one of the following errors: SQL1131N "DARI (Stored Procedure) process has been terminated abnormally", or SQL0444N "Routine (specific name ) is implemented with code in library or path , function which cannot be accessed. Reason code: ".

Cause

There may be several different causes for the SQL1131N or SQL0444N errors in this situation. For example:

  1. The licence keys in Micro Focus (MF) COBOL expire after a certain number of uses. Every invocation of a MF COBOL stored procedure will use up a license key. These license keys will get refreshed after a set time limit. If a stored procedure is executed when these license keys expire, then MF COBOL will abort the stored procedure in such a way that would cause DB2 LUW to return an SQL1131N error message.
  2. With DB2 LUWVersion 8.2 GA or later and MF COBOL Server Express 4.0 or higher it is necessary to set up DB2 LUW to properly pass in environment settings to the stored procedure infrastructure. If the COBDIR and LIBPATH or LD_LIBRARY_PATH variables are not set up properly for the COBOL runtime when executing within the procedure, then the procedure loading may fail with an SQL0444N or SQL1131N.
  3. There may be a file locking problem on the file SYSOUT that is considered a fatal error and will cause the COBOL program to stop

Answer

There are several things to keep in mind when determining the cause of the SQL1131N SQL0444N error:

  1. If you are using DB2 LUW Version 7, note that APAR IY24835 was opened to add complete support for Micro Focus COBOL stored procedures in DB2 LUW Version 7. This APAR is implemented in DB2 LUW Version 7.2 FixPak 6. DB2 LUW Version 8.1 GA includes this APAR as well.
  2. If the suspected cause of the error is the expiration of Micro Focus COBOL license keys, then you should contact Micro Focus support for instructions on how to correct the licensing problem.
  3. If the suspected cause of the error is due to locking on the SYSOUT file, recompile the COBOL code using the compiler directive SHARE-OUTDD
  4. With DB2 LUW Version 8.2 GA or later and Micro Focus COBOL Server Express 4.0 or higher, it is recommended that the following settings be set.
    • The DB2ENVLIST registry variable should include the COBDIR environment variable. This setting will pass the COBDIR environment variable into the stored procedure infrastructure so that the Micro Focus runtime has access to COBDIR. It is important that the instance owner have COBDIR defined correctly so that this value is picked up. You can set this by running:
      db2set DB2ENVLIST=COBDIR
    • The DB2LIBPATH registry variable should include the $COBDIR/lib directory in its list. If there are other directories in this list, $COBDIR/lib may be appended. Otherwise, it can be set by running:
      db2set DB2LIBPATH=$COBDIR/lib
    • The Micro Focus runtime libraries must be copied to a trusted directory since the program that does the loading sometimes runs with setuid privileges. It will only look for dependent libraries in a trusted directory such as /usr/lib. Symbolic links to /usr/lib for the COBOL shared libraries should be created, or the libraries copied directly. This must be done as root. The simplest way to do this is to link all COBOL library files from $COBDIR/lib to /usr/lib by executing the following command:
      ln -s $COBDIR/lib/libcob* /usr/lib
  5. When trying to determine the cause of problems related to running Micro Focus stored procedures, it is important to ensure that the sample procedures load and execute properly. This will ensure that the Micro Focus COBOL compiler is working properly and that the environment is set up correctly for the current user. In the $DB2PATH/sqllib/samples/cobol_mf directory, there is a sample stored procedure called inpsrv. The calling application is called inpcli. To build and run this sample, follow these steps:
    1. Start the database manager: db2start
    2. Create the sample database: db2sampl
    3. Compile the calling application: bldapp inpcli
    4. Compile the stored procedure: bldrtn inpsrv
    5. Catalog the stored procedure: spcat
    6. Run the test: inpcli
    The output should look like this:
    Use CALL to invoke the INPSRV stored procedure.
    The SQLCODE from the stored procedure is: 0
    Server Procedure Complete.

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Routines (SP & UDF) - SQL","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;10.1;10.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21049516