IBM AS/400 Define the prototype for the cancel handler. This procedure is, a local procedure

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 269
Image 269
*Define the prototype for the cancel handler. This procedure is

handler remains in effect until the call stack entry is removed, or called to disable itSystem. See APItheReferencefor more information on these ILE bindable APIs.

Figure 118 shows an example of enabling and coding a cancel handler f procedure. (Cancel handlers can also be enabled for main procedures way.)

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

*Define the prototype for the cancel handler. This procedure is

*a local procedure.

 

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

 

 

D CanHdlr

PR

 

 

D

pMsg

 

*

 

 

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

 

 

 

* Define the prototype for a subprocedure to enable the can￿cel

 

* handler.

 

 

 

 

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

 

 

D Enabler

PR

 

 

 

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

 

 

 

* Define the prototype for a subprocedure to call Enabler

 

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

 

 

D SubProc

PR

 

 

 

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

 

 

 

* Main procedure. Call SubProc three times.

 

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

 

 

C

 

CALLP

SubProc

C

 

CALLP

SubProc

C

 

CALLP

SubProc

C

 

SETON

LR

 

 

 

 

 

Figure

118 (Part

1 of 4).

Enabling and Coding a Cancel Handler for a Subprocedure

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

*Procedure SubProc. Call Enabler. Since this call will fail,

*define a local *PSSR subroutine to handle the error.

 

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

 

 

P SubProc

B

 

 

C

 

CALLP

Enabler

 

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

 

 

 

* The PSSR has a RETURN operation, so the call from the main

 

* procedure to SubProc will not fail.

 

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

 

 

C

*PSSR

BEGSR

 

 

C

'Subproc PSSR'DSPLY

 

 

C

 

RETURN

 

 

C

 

ENDSR

 

 

P SubProc

E

 

 

 

 

 

 

 

Figure

118 (Part

2 of 4).

Enabling and Coding a Cancel Handler for a Subprocedure

Chapter 12. Handling Exceptions245

Page 269
Image 269
IBM AS/400 manual Define the prototype for the cancel handler. This procedure is, a local procedure, Handling Exceptions245