IBM AS/400 manual Using a File Error INFSR Subroutine, Begsr

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 253
Image 253

subroutine is called again.

The

procedure

will loop

unless

you cod

tine

to

avoid

this problem.

 

 

 

 

To see

how

to

code an error

subroutine

to avoid

such

a loop, s

Loop

in

an

Error Subroutine”

on

page 235.

 

 

 

Using a File Error (INFSR) Subroutine

To handle a file error or exception in a main procedure you can wr (INFSR) subroutine. When a file exception occurs:

1. The INFDS is updated.

2. A file error subroutine (INFSR) receives control if the exception

¹ On an implicit (primary or secondary) file operation

¹On an explicit file operation that does not have an indicator

positions 73 - 74.

A file error subroutine can handle errors in more than one file.

The

following restrictions

apply:

 

 

 

 

¹

If

a file

exception

occurs

during the

start or

end of a progr

 

an implicit open at the start

of

the cycle) control passes to th

 

exception handler, and not to

the

error

subroutine

handler. Conseque

 

file

error

subroutine

will not

be

processed.

 

¹If an error occurs that is not related to the operation (for index error on a CHAIN operation), then any INFSR error subroutine

ignored. The error would be treated like any other program error

¹ An INFSR cannot handle errors in a file used by a subprocedure.

To add a file error subroutine to your program, you do the followi

1.Enter the name of the subroutine after the keyword INFSR on a Description specification. The subroutine name can be *PSSR, which i

that the program error subroutine is given control for the except

2.Optionally identify the file information data structure on a File ification using the keyword INFDS.

3. Enter

a

BEGSR

operation where

the

Factor 1 entry contains the sa

tine

name

that

is specified

for

the keyword INFSR.

4.Identify a return point, if any, and code it on the ENDSR oper routine. For a discussion of the valid entries for Factor 2, see

Return Point in the ENDSR Operation” on page 237.

5. Code

the

rest of

the

file

error subroutine.

While

any

of

the

operations

can

be used in the file error subroutine, it

is

not

you

use

I/O

operations to

the same

file that got

the

error. Th

tion

must

be

the

last

specification

for the

file error

subroutine

Figure 111 on page 230 shows an example of exception handling using a error subroutine. The program TRNSUPDT is a simple inventory update pro uses a transaction file TRANSACT to update a master inventory file PRDMA I/O error occurs, then the INFSR error subroutine is called. If it error, then the record is written to a backlog file. Otherwise, an issued.

Chapter 12. Handling Exceptions229

Page 253
Image 253
IBM AS/400 manual Using a File Error INFSR Subroutine, Begsr