302 lines
14 KiB
HTML
302 lines
14 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Example in ILE COBOL: Reporting software error (ILE API with pointers)" />
|
||
|
<meta name="abstract" content="This program registers an ILE COBOL Error Handler. After the successful completion of the registration of the error handler, this, program creates a decimal data error. This exception causes the error handler to be called which then logs the software error." />
|
||
|
<meta name="description" content="This program registers an ILE COBOL Error Handler. After the successful completion of the registration of the error handler, this, program creates a decimal data error. This exception causes the error handler to be called which then logs the software error." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="opmIlecompare.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="opmReportingILECOBOL" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Example in ILE COBOL: Reporting software error (ILE API with pointers)</title>
|
||
|
</head>
|
||
|
<body id="opmReportingILECOBOL"><a name="opmReportingILECOBOL"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example in ILE COBOL: Reporting software error (ILE API with pointers)</h1>
|
||
|
<div><p>This program registers an ILE COBOL Error Handler. After the successful
|
||
|
completion of the registration of the error handler, this, program creates
|
||
|
a decimal data error. This exception causes the error handler to be called
|
||
|
which then logs the software error.</p>
|
||
|
<div class="section"><p>This program calls the Report Software Error (QpdReportSoftwareError)
|
||
|
API to perform FFDC, and uses pointers. The ILE program sets a pointer, as
|
||
|
shown at <a href="#opmReportingILECOBOL__Num2">(2)</a> to point to the
|
||
|
same location as in the <a href="opmLoggingILEC.htm">OPM program</a> at <span class="uicontrol">(1)</span>.</p>
|
||
|
<p>This
|
||
|
example uses two programs: <a href="#opmReportingILECOBOL__CBLERR2">CBLERR2 program</a> causes
|
||
|
the error, and <a href="#opmReportingILECOBOL__ERRHDL2">ERRHDL2 program</a> shows how
|
||
|
to report the software error using the QPDLOGER API.</p>
|
||
|
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for important legal information.</div>
|
||
|
</div>
|
||
|
<div class="section" id="opmReportingILECOBOL__CBLERR2"><a name="opmReportingILECOBOL__CBLERR2"><!-- --></a><h4 class="sectiontitle">CBLERR2 program</h4><pre> PROCESS NOMONOPRC.
|
||
|
IDENTIFICATION DIVISION.
|
||
|
***************************************************************
|
||
|
***************************************************************
|
||
|
*
|
||
|
* Program: Register an ILE COBOL Error Handler
|
||
|
* Cause a decimal data exception to demonstrate
|
||
|
* logging of software errors
|
||
|
*
|
||
|
* Language: ILE COBOL
|
||
|
*
|
||
|
* Description: This program registers an ILE COBOL Error
|
||
|
* Handler. After the successful completion of
|
||
|
* the registration of the error handler, this ,
|
||
|
* program creates a decimal data error. This
|
||
|
* exception causes the error handler to be
|
||
|
* called which then logs the software error.
|
||
|
*
|
||
|
* APIs Used: QlnSetCobolErrorHandler
|
||
|
*
|
||
|
*
|
||
|
***************************************************************
|
||
|
*
|
||
|
***************************************************************
|
||
|
PROGRAM-ID. CBLERR2.
|
||
|
ENVIRONMENT DIVISION.
|
||
|
CONFIGURATION SECTION.
|
||
|
SOURCE-COMPUTER. IBM-AS400.
|
||
|
OBJECT-COMPUTER. IBM-AS400.
|
||
|
SPECIAL-NAMES.
|
||
|
LINKAGE TYPE PROCEDURE FOR "QlnSetCobolErrorHandler".
|
||
|
INPUT-OUTPUT SECTION.
|
||
|
FILE-CONTROL.
|
||
|
DATA DIVISION.
|
||
|
WORKING-STORAGE SECTION.
|
||
|
*
|
||
|
* Error Code parameter include. As this sample program
|
||
|
* uses COPY to include the error code structure, only the first
|
||
|
* 16 bytes of the error code structure are available. If the
|
||
|
* application program needs to access the variable length
|
||
|
* exception data for the error, the developer should physically
|
||
|
* copy the QSYSINC include and modify the copied include to
|
||
|
* define additional storage for the exception data.
|
||
|
*
|
||
|
COPY QUSEC OF QSYSINC-QCBLLESRC.
|
||
|
*
|
||
|
* Miscellaneous elements
|
||
|
*
|
||
|
01 MISC.
|
||
|
05 Y PIC S9(09) VALUE 0.
|
||
|
01 ERROR-HANDLER PROCEDURE-POINTER.
|
||
|
01 OLD-ERROR-HANDLER PROCEDURE-POINTER.
|
||
|
01 NUMERIC-GROUP.
|
||
|
05 X PIC 9(03).
|
||
|
*
|
||
|
* Beginning of mainline
|
||
|
*
|
||
|
PROCEDURE DIVISION.
|
||
|
MAIN-LINE.
|
||
|
*
|
||
|
* Register the COBOL Error Handler.
|
||
|
*
|
||
|
* Initialize the error code parameter. To signal exceptions to
|
||
|
* this program by the API, you need to set the bytes provided
|
||
|
* field of the error code to zero. Because this program has
|
||
|
* exceptions sent back through the error code parameter, it sets
|
||
|
* the bytes provided field to the number of bytes it gives the
|
||
|
* API for the parameter.
|
||
|
*
|
||
|
MOVE 16 TO BYTES-PROVIDED.
|
||
|
*
|
||
|
* Set ERROR-HANDLER procedure pointer to entry point of
|
||
|
* ERRHDL1 *PGM
|
||
|
*
|
||
|
SET ERROR-HANDLER TO ENTRY LINKAGE PROGRAM "ERRHDL2".
|
||
|
*
|
||
|
*
|
||
|
* Call the API to register the exit point.
|
||
|
*
|
||
|
CALL "QlnSetCobolErrorHandler" USING ERROR-HANDLER,
|
||
|
OLD-ERROR-HANDLER,
|
||
|
QUS-EC.
|
||
|
*
|
||
|
* If an exception occurs, the API returns the exception in the
|
||
|
* error code parameter. The bytes available field is set to
|
||
|
* zero if no exception occurs and greater than zero if an
|
||
|
* exception does occur.
|
||
|
*
|
||
|
IF BYTES-AVAILABLE > 0
|
||
|
DISPLAY "Error setting handler",
|
||
|
STOP RUN.
|
||
|
*
|
||
|
* If the call to register an error handler is successful, then
|
||
|
* cause a the data decimal error (X is initialized to blanks).
|
||
|
*
|
||
|
ADD X TO Y.
|
||
|
*
|
||
|
* Should not get here due to data decimal error
|
||
|
*
|
||
|
STOP RUN.
|
||
|
*
|
||
|
* End of MAINLINE
|
||
|
*</pre>
|
||
|
</div>
|
||
|
<div class="section" id="opmReportingILECOBOL__ERRHDL2"><a name="opmReportingILECOBOL__ERRHDL2"><!-- --></a><h4 class="sectiontitle">ERRHDL2 program</h4><pre> PROCESS NOMONOPRC.
|
||
|
IDENTIFICATION DIVISION.
|
||
|
***************************************************************
|
||
|
***************************************************************
|
||
|
*
|
||
|
* Program: Log a software error
|
||
|
*
|
||
|
* Language: ILE COBOL
|
||
|
*
|
||
|
* Description: This program receives control for exceptions
|
||
|
* within a COBOL run unit. This program is used
|
||
|
* in conjunction with CBLERR2. ,
|
||
|
* Any exception causes this error handler to be
|
||
|
* called which then logs the software error.
|
||
|
*
|
||
|
* APIs Used: QpdReportSoftwareError
|
||
|
*
|
||
|
***************************************************************
|
||
|
*
|
||
|
***************************************************************
|
||
|
PROGRAM-ID. ERRHDL2.
|
||
|
ENVIRONMENT DIVISION.
|
||
|
CONFIGURATION SECTION.
|
||
|
SOURCE-COMPUTER. IBM-AS400.
|
||
|
OBJECT-COMPUTER. IBM-AS400.
|
||
|
SPECIAL-NAMES.
|
||
|
LINKAGE TYPE PROCEDURE FOR "QpdReportSoftwareError".
|
||
|
INPUT-OUTPUT SECTION.
|
||
|
FILE-CONTROL.
|
||
|
DATA DIVISION.
|
||
|
WORKING-STORAGE SECTION.
|
||
|
*
|
||
|
* Error Code parameter include. As this sample program
|
||
|
* uses COPY to include the error code structure, only the first
|
||
|
* 16 bytes of the error code structure are available. If the
|
||
|
* application program needs to access the variable length
|
||
|
* exception data for the error, the developer should physically
|
||
|
* copy the QSYSINC include and modify the copied include to
|
||
|
* define additional storage for the exception data.
|
||
|
*
|
||
|
COPY QUSEC OF QSYSINC-QCBLLESRC.
|
||
|
*
|
||
|
* QpdReportSoftwareError include
|
||
|
*
|
||
|
COPY QPDSRVPG OF QSYSINC-QCBLLESRC.
|
||
|
*
|
||
|
* Miscellaneous elements
|
||
|
*
|
||
|
01 MISC.
|
||
|
05 NBR-OF-RECORDS PIC S9(09) BINARY VALUE 0.
|
||
|
05 MSG-KEYWORD PIC X(03) VALUE "MSG".
|
||
|
01 PROBLEM-RECORDS.
|
||
|
05 PROBLEM-POINTER POINTER OCCURS 100 TIMES.
|
||
|
LINKAGE SECTION.
|
||
|
01 CBL-EXCEPTION-ID PIC X(07).
|
||
|
01 VALID-RESPONSES PIC X(06).
|
||
|
01 PGM-IN-ERROR.
|
||
|
05 PGM-NAME PIC X(10).
|
||
|
05 LIB-NAME PIC X(10).
|
||
|
01 SYS-EXCEPTION-ID PIC X(07).
|
||
|
01 MESSAGE-TEXT PIC X(01).
|
||
|
01 MESSAGE-LENGTH PIC S9(09) BINARY.
|
||
|
01 SYS-OPTION PIC X(01).
|
||
|
01 ERR-MODULE-NAME PIC X(10).
|
||
|
01 CBL-PGM-NAME PIC X(256).
|
||
|
*
|
||
|
* Beginning of mainline
|
||
|
*
|
||
|
PROCEDURE DIVISION USING CBL-EXCEPTION-ID,
|
||
|
VALID-RESPONSES,
|
||
|
PGM-IN-ERROR,
|
||
|
SYS-EXCEPTION-ID,
|
||
|
MESSAGE-LENGTH,
|
||
|
SYS-OPTION,
|
||
|
MESSAGE-TEXT,
|
||
|
ERR-MODULE-NAME,
|
||
|
CBL-PGM-NAME.
|
||
|
MAIN-LINE.
|
||
|
*
|
||
|
* Initialize the error code parameter. To signal exceptions to
|
||
|
* this program by the API, you need to set the bytes provided
|
||
|
* field of the error code to zero. Because this program has
|
||
|
* exceptions sent back through the error code parameter, it sets
|
||
|
* the bytes provided field to the number of bytes it gives the
|
||
|
* API for the parameter.
|
||
|
*
|
||
|
MOVE 16 TO BYTES-PROVIDED.
|
||
|
*
|
||
|
* Record the COBOL Program and Library names
|
||
|
*
|
||
|
MOVE 101 TO KEY-FIELD OF QPD-SUSPECTED-PROGRAM.
|
||
|
MOVE 10 TO PROGRAM-NAME-LENGTH OF QPD-SUSPECTED-PROGRAM.
|
||
|
MOVE 10 TO LIBRARY-NAME-LENGTH OF QPD-SUSPECTED-PROGRAM.
|
||
|
SET PROGRAM-NAME OF QPD-SUSPECTED-PROGRAM <span class="uicontrol" id="opmReportingILECOBOL__Num2"><a name="opmReportingILECOBOL__Num2"><!-- --></a>(2)</span>
|
||
|
TO ADDRESS OF PGM-NAME OF PGM-IN-ERROR.
|
||
|
SET LIBRARY-NAME OF QPD-SUSPECTED-PROGRAM
|
||
|
TO ADDRESS OF LIB-NAME OF PGM-IN-ERROR.
|
||
|
ADD 1 TO NBR-OF-RECORDS.
|
||
|
SET PROBLEM-POINTER (NBR-OF-RECORDS) TO
|
||
|
ADDRESS OF QPD-SUSPECTED-PROGRAM.
|
||
|
*
|
||
|
* Record the message id
|
||
|
*
|
||
|
MOVE 200 TO KEY-FIELD OF QPD-SYMPTOM.
|
||
|
MOVE 3 TO KEYWORD-LENGTH OF QPD-SYMPTOM.
|
||
|
MOVE 7 TO DATA-LENGTH OF QPD-SYMPTOM.
|
||
|
MOVE "C" TO DATA-TYPE OF QPD-SYMPTOM.
|
||
|
SET KEYWORD OF QPD-SYMPTOM TO ADDRESS OF MSG-KEYWORD.
|
||
|
SET DATA-FIELD OF QPD-SYMPTOM TO ADDRESS OF SYS-EXCEPTION-ID.
|
||
|
ADD 1 TO NBR-OF-RECORDS.
|
||
|
SET PROBLEM-POINTER (NBR-OF-RECORDS) TO
|
||
|
ADDRESS OF QPD-SYMPTOM.
|
||
|
*
|
||
|
* For illustration purposes, dump the program object
|
||
|
*
|
||
|
MOVE 302 TO KEY-FIELD OF QPD-NAMED-SYSTEM-OBJECT.
|
||
|
MOVE PGM-NAME OF PGM-IN-ERROR
|
||
|
TO OBJECT-NAME OF QPD-NAMED-SYSTEM-OBJECT.
|
||
|
MOVE LIB-NAME OF PGM-IN-ERROR
|
||
|
TO OBJECT-LIBRARY OF QPD-NAMED-SYSTEM-OBJECT.
|
||
|
MOVE "*PGM" TO OBJECT-TYPE OF QPD-NAMED-SYSTEM-OBJECT.
|
||
|
ADD 1 TO NBR-OF-RECORDS.
|
||
|
SET PROBLEM-POINTER (NBR-OF-RECORDS) TO
|
||
|
ADDRESS OF QPD-NAMED-SYSTEM-OBJECT.
|
||
|
*
|
||
|
* Call the API to log the software error.
|
||
|
*
|
||
|
CALL "QpdReportSoftwareError" USING PROBLEM-RECORDS,
|
||
|
NBR-OF-RECORDS,
|
||
|
QUS-EC.
|
||
|
*
|
||
|
* If an exception occurs, the API returns the exception in the
|
||
|
* error code parameter. The bytes available field is set to
|
||
|
* zero if no exception occurs and greater than zero if an
|
||
|
* exception does occur.
|
||
|
*
|
||
|
IF BYTES-AVAILABLE > 0 DISPLAY "Cannot log error".
|
||
|
*
|
||
|
* End the current run unit
|
||
|
*
|
||
|
MOVE "C" TO SYS-OPTION.
|
||
|
STOP RUN.
|
||
|
*
|
||
|
* End of MAINLINE
|
||
|
*</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="opmIlecompare.htm" title="This topic gives an overview of how Original Program Model (OPM) APIs and Integrated Language Environment (ILE) APIs differ from each other. The ILE APIs include the UNIX-type APIs and the ILE CEE APIs, among others.">OPM and ILE API differences</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|