215 lines
9.5 KiB
HTML
215 lines
9.5 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 OPM RPG: Logging software error (OPM API without pointers)" />
|
||
|
<meta name="abstract" content="This program performs a divide-by-0 operation to cause an exception. This exception is caught using RPG *PSSR support, and the exception is then logged as a software error." />
|
||
|
<meta name="description" content="This program performs a divide-by-0 operation to cause an exception. This exception is caught using RPG *PSSR support, and the exception is then logged as a software error." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="opmIlecompare.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="opmLoggingILEC.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="opmLoggingRPG" />
|
||
|
<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 OPM RPG: Logging software error (OPM API without pointers)</title>
|
||
|
</head>
|
||
|
<body id="opmLoggingRPG"><a name="opmLoggingRPG"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example in OPM RPG: Logging software error (OPM API without pointers)</h1>
|
||
|
<div><p>This program performs a divide-by-0 operation to cause an exception.
|
||
|
This exception is caught using RPG *PSSR support, and the exception
|
||
|
is then logged as a software error.</p>
|
||
|
<div class="section"><p>Refer to Example in ILE C: Logging software error (OPM API without
|
||
|
pointers) for the original example.</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>
|
||
|
<pre>
|
||
|
F****************************************************************
|
||
|
F*
|
||
|
F* Program: Demonstrate use of OPM-based Log Software Error
|
||
|
F*
|
||
|
F* Language: OPM RPG
|
||
|
F*
|
||
|
F* Description: This program performs a divide-by-0 operation
|
||
|
F* to cause an exception. This exception is
|
||
|
F* caught using RPG *PSSR support,
|
||
|
F* and the exception is then logged as a
|
||
|
F* software error.
|
||
|
F*
|
||
|
F* APIs used: QPDLOGER
|
||
|
F*
|
||
|
F****************************************************************
|
||
|
E*
|
||
|
E* Arrays used to extract source line number where error happened
|
||
|
E*
|
||
|
E SRC 8 1
|
||
|
E TGT 8 1
|
||
|
I*
|
||
|
I* Error Code parameter include. As this sample program uses
|
||
|
I* /COPY to include the error code structure, only the first
|
||
|
I* 16 bytes of the error code structure are available. If the
|
||
|
I* application program needs to access the variable length
|
||
|
I* exception data for the error, the developer should physically
|
||
|
I* copy the QSYSINC include and modify the copied include to
|
||
|
I* define additional storage for the exception data.
|
||
|
I*
|
||
|
I/COPY QSYSINC/QRPGSRC,QUSEC
|
||
|
I*
|
||
|
I* Define Program Status Data Structure
|
||
|
I*
|
||
|
IPSDS SDS
|
||
|
I 1 10 PGMNAM
|
||
|
I 11 150STATUS
|
||
|
I 21 28 SRC
|
||
|
I 40 46 EXCPID
|
||
|
I 81 90 LIBNAM
|
||
|
I*
|
||
|
I* Some miscellaneous fields
|
||
|
I*
|
||
|
IMISC DS
|
||
|
I B 1 40FAILPT
|
||
|
I B 5 80DATA#
|
||
|
I B 9 120OBJS#
|
||
|
I 13 20 TGT
|
||
|
I 13 200LIN#C
|
||
|
I*
|
||
|
I* DATA represents the data items to report as part of problem
|
||
|
I*
|
||
|
IDATA DS 4096
|
||
|
I*
|
||
|
I* DATAPT defines (via offset and length values) how to read DATA
|
||
|
I*
|
||
|
IDATAPT DS 256
|
||
|
I B 1 40DTAOFF
|
||
|
I B 5 80DTALEN
|
||
|
I*
|
||
|
I* OBJS represents the list of objects to spool as part of problem
|
||
|
I*
|
||
|
IOBJS DS 2590
|
||
|
I 1 30 OBJ1N
|
||
|
I 31 60 OBJ1L
|
||
|
I 61 70 OBJ1T
|
||
|
C*
|
||
|
C* Prepare for divide-by-zero situation
|
||
|
C*
|
||
|
C Z-ADD10 FACT1 50
|
||
|
C Z-ADD0 FACT2 50
|
||
|
C*
|
||
|
C* and divide by 0
|
||
|
C*
|
||
|
C FACT1 DIV FACT2 RESULT 50
|
||
|
C*
|
||
|
C* should not get here due to divide-by-0 exception
|
||
|
C*
|
||
|
C MOVE '1' *INLR
|
||
|
C RETRN
|
||
|
C*
|
||
|
C* Program exception subroutine:
|
||
|
C*
|
||
|
C *PSSR BEGSR
|
||
|
C*
|
||
|
C* Make sure we are not catching an exception due to the *PSSR
|
||
|
C* subroutine itself
|
||
|
C*
|
||
|
C SWITCH IFEQ ' '
|
||
|
C MOVE '1' SWITCH 1
|
||
|
C*
|
||
|
C* Set API error code to work in nonexception mode
|
||
|
C*
|
||
|
C Z-ADD16 QUSBNB
|
||
|
C*
|
||
|
C* Record the source listing line number that caused the failure
|
||
|
C*
|
||
|
C* First, extract the numeric portion of the PSDS line number
|
||
|
C*
|
||
|
C Z-ADD8 X 10
|
||
|
C Z-ADD8 Y 10
|
||
|
C Z-ADD0 LIN#C
|
||
|
C SRC,X DOWEQ' '
|
||
|
C SUB 1 X
|
||
|
C END
|
||
|
C X DOWGT0
|
||
|
C MOVE SRC,X TGT,Y
|
||
|
C SUB 1 X
|
||
|
C SUB 1 Y
|
||
|
C END
|
||
|
C*
|
||
|
C* Then record it:
|
||
|
C*
|
||
|
C Z-ADDLIN#C FAILPT
|
||
|
C*
|
||
|
C* Record the status code for the failure
|
||
|
C*
|
||
|
C MOVELSTATUS DATA
|
||
|
C*
|
||
|
C* Record where to find the status data within DATA
|
||
|
C*
|
||
|
C Z-ADD0 DTAOFF
|
||
|
C Z-ADD5 DTALEN
|
||
|
C Z-ADD1 DATA#
|
||
|
C*
|
||
|
C* For illustration purposes also dump the program object as
|
||
|
C* part of logging the software error
|
||
|
C*
|
||
|
C MOVELPGMNAM OBJ1N <span class="uicontrol">(1)</span>
|
||
|
C MOVELLIBNAM OBJ1L
|
||
|
C MOVEL'*PGM' OBJ1T
|
||
|
C Z-ADD1 OBJS#
|
||
|
C*
|
||
|
C* Call the Log Software Error API
|
||
|
C*
|
||
|
C CALL 'QPDLOGER'
|
||
|
C PARM PGMNAM
|
||
|
C PARM EXCPID MSGID 12
|
||
|
C PARM MSGKEY 4
|
||
|
C PARM FAILPT
|
||
|
C PARM 'Y' JOBLOG 1
|
||
|
C PARM DATA
|
||
|
C PARM DATAPT
|
||
|
C PARM DATA#
|
||
|
C PARM OBJS
|
||
|
C PARM OBJS#
|
||
|
C PARM QUSBN
|
||
|
C*
|
||
|
C* If an error on the API call, then indicate a terminal error
|
||
|
C*
|
||
|
C QUSBNC IFGT 0
|
||
|
C 'TERM ERR'DSPLY
|
||
|
C END
|
||
|
C ELSE
|
||
|
C*
|
||
|
C* If error within *PSSR, then indicate *PSSR error
|
||
|
C*
|
||
|
C '*PSSR 'DSPLY
|
||
|
C END
|
||
|
C*
|
||
|
C* No matter how the program got to the *PPSR, end the program
|
||
|
C*
|
||
|
C MOVE '1' *INLR
|
||
|
C RETRN
|
||
|
C ENDSR</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 class="relref"><strong>Related reference</strong><br />
|
||
|
<div><a href="opmLoggingILEC.htm" title="This program illustrates how to use APIs to log software errors using FFDC.">Example in ILE C: Logging software error (OPM API without pointers)</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|