IBM AS/400 manual Using, Cancel, Handlers, APIs

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 268
Image 268
Cancel

 

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

 

* *PSSR: Error Subroutine for the procedure

*

 

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

C

*PSSR

BEGSR

 

 

C

 

 

EXCEPT

InPssr

 

C

 

 

EXCEPT

Cancelling

 

 

C

 

ENDSR

'*CANCL'

 

 

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

 

* Procedure Output

 

 

*

 

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

OQSYSPRT

E

ImBack

 

 

O

 

 

 

 

'I''m Back'

OQSYSPRT

E

InPssr

 

 

O

 

 

 

 

'In PSSR'

OQSYSPRT

E

Cancelling

 

O

 

 

 

 

'Cancelling...'

 

 

 

 

 

Figure

117

(Part 3

of 3).

Source for Registering a Condition Handler

If you want to try these procedures, follow these steps:

1.To create the procedure RPGHDLR, using the source shown in Figure page 239, type:

CRTRPGMOD MODULE(MYLIB/RPGHDLR)

2.To create the procedure SHOWERR, using the source shown in Figure page 242, type:

CRTRPGMOD MODULE(MYLIB/SHOWERR)

3. To create the program, ERRORTEST, type

CRTPGM PGM(MYLIB/ERRORTEST) MODULE(SHOWERR RPGHDLR)

4. To run the program ERRORTEST, type:

OVRPRTF FILE(QSYSPRT) SHARE(*YES)

CALL PGM(MYLIB/ERRORTEST)

 

The output is shown below:

HDLR: In Handler for SHOWERR

HDLR: Handling...

I'm Back

HDLR: In Handler for SHOWERR

HDLR: Percolating...

In PSSR

Cancelling...

Using

Cancel

Handlers

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Cancel handlers provide an important

function

by allowing

you

 

to

get

cont

 

 

clean-up and recovery actions when

call

stack

entries

are

terminated

by

 

 

other than a normal return. For example, you might want one

to

get

cont

 

 

procedure ends via a system request '2', or because an

 

inquiry

messa

 

 

answered with 'C' (Cancel).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The

Register Call

Stack Entry

Termination

User

Exit

Procedure

(CEERTX)

and

 

 

Call Stack Entry Termination User Exit Procedure

(CEEUTX)

ILE

bindable

APIs

 

 

provide a

way of

dynamically

registering a

user-defined

routine

to

be

 

 

call

stack entry for which it is

registered

is

cancelled.

Once

regis

244

ILE RPG

for AS/400

Programmer's

Guide

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 268
Image 268
IBM AS/400 manual Using, Cancel, Handlers, APIs