IBM AS/400 manual ILE Condition Handlers, Show exception handling using a user-defined

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 266
Image 266
Show exception handling using a user-defined

ILE Condition Handlers

 

*=================================================================*

 

* SHOWERR:

 

Show exception handling using a user-defined

*

 

*

 

exception handler.

 

*

 

*=================================================================*

FQSYSPRT

O

F 132

PRINTER

 

 

 

*-----------------------------------------------------------------

 

 

 

*

 

* The following are the parameter definitions for the CEEH￿DLR

*

 

* API. The first is the procedure pointer to the

*

 

* procedure which will handle the exception. The second

*

 

* is a pointer to a communication area which will be passed￿

*

 

* to the exception handling procedure. In this example, this

*

 

* area will contain a pointer to the PSDS of this module, and￿

*

 

* an indicator telling whether an error is allowed.

*

 

*

 

 

 

 

*

 

* We should make sure this program (SHOWERR) does not ignore￿ any

*

 

* handled errors, so we will check the 'Error' indicator afte￿r

*

 

* any operation that might cause an error that RPGHDLR will￿

*

 

* "allow".

We will also check at the end of the program to make

*

 

* sure we didn't miss any errors.

 

*

 

*-----------------------------------------------------------------

 

 

 

*

D pConHdlr

 

S

*

PROCPTR

 

D

 

 

 

 

INZ(%paddr('RPGHDLR'))

 

 

*-----------------------------------------------------------------

 

 

 

*

 

* Communication area

 

 

*

 

*-----------------------------------------------------------------

 

 

 

*

D CommArea

 

DS

 

NOOPT

 

D

pPsds

 

 

*

INZ(%ADDR(DSPsds))

 

D

AllowError

 

1N

INZ('0')

 

 

*-----------------------------------------------------------------

 

 

 

*

 

* PSDS

 

 

 

 

*

 

*-----------------------------------------------------------------

 

 

 

*

D DSPsds

 

SDS

 

NOOPT

 

D

ProcName

*PROC

 

 

 

 

*-----------------------------------------------------------------

 

 

 

*

 

* Variables that will be used to cause errors

*

 

*-----------------------------------------------------------------

 

 

 

*

D Arr1

 

S

10A

DIM(5)

 

D Num

 

S

5P 0

 

 

 

*-----------------------------------------------------------------

 

 

 

*

 

* CEEHDLR Interface

 

 

*

 

*-----------------------------------------------------------------

 

 

 

*

D CEEHDLR

 

PR

 

 

 

D

pConHdlr

 

*

PROCPTR

 

D

CommArea

 

*

CONST

 

D

Feedback

 

12A

OPTIONS(*OMIT)

 

 

*-----------------------------------------------------------------

 

 

 

*

 

* CEEHDLU Interface

 

 

*

 

*-----------------------------------------------------------------

 

 

 

*

D CEEHDLU

 

PR

 

 

 

D

pConHdlr

 

*

PROCPTR

 

D

Feedback

 

12A

OPTIONS(*OMIT)

 

Figure 117 (Part 1 of 3). Source for Registering a Condition Handler

242 ILE RPG for AS/400 Programmer's Guide

Page 266
Image 266
IBM AS/400 manual ILE Condition Handlers, Show exception handling using a user-defined