Question & Answer
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: ".
There may be several different causes for the SQL1131N or SQL0444N errors in this situation. For example:
- 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.
- 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.
- 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
There are several things to keep in mind when determining the cause of the SQL1131N SQL0444N error:
- 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.
- 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.
- 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
- 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:
- 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:
- 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
- Start the database manager: db2start
- Create the sample database: db2sampl
- Compile the calling application: bldapp inpcli
- Compile the stored procedure: bldrtn inpsrv
- Catalog the stored procedure: spcat
- 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.
16 June 2018