Qus_Vlen_Rec_4_t CCSID_rec;

 

 

 

 

int

CCSID;

 

 

 

 

} addep_attributes;

 

 

 

 

 

The num_rec field is set to the value of 2

because

the

example

variable-length records. The replace_rec field

contains

the

length of

length record (value of

16), the key (value

of 4),

and

the length

1). The replace field contains the data for the replace key. The R

reserves 3 bytes to force the next

record to

start

on a 4-byte

The 3 bytes

that are reserved are counted as part

of the

length

variable-length

record. The next record

then follows

the

first

record

Error Handling

Error handling with ILE APIs can be accomplished in two ways: use the parameter or have exceptions signaled by the API to your applicatio

Error Handling through the Error Code Parameter

The error code parameter enables a user to have exceptions returne program through the use of the parameter instead of having the exc naled. Some exceptions may be signaled to the caller regardless of t error code parameter. These exceptions are usually from errors that error code parameter itself (that is, message CPF3CF1) or with one o parameters (that is, message CPF9872). In the latter case, message CPF9 always signaled and never returned through the error code parameter API is unable to verify the error code parameter before the exc

The caller

of

the API must

initialize the error code parameter

so

vided field

is

set to the

size,

in bytes, of the error code

pa

the

error_code_struct structure on

page 4-3 sets the size at

11

the

error

code

parameter,

do the

following:

 

1.Allocate storage for the error code parameter: error_code_struct error_code;

2. Initialize

the

bytes provided

field

to

the

number

of

bytes

th

the

parameter:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

error_code.ec_fields.Bytes_Provided=sizeof(error_code_str￿uct);

 

 

 

 

If

the bytes provided field is set

to

 

a

value

equal

to

or

grea

wants all exceptions

returned

through the

error

code

parameter.

The

of

the message information up to the

size of the error code

para

Error

Determination—Example:

 

 

On

the return

from

the

call

to

the

API,

ver

whether

or

not

an

error

occurred. If

an error occurred, the byte

set

to

something

other than

zero. If

the bytes available field is

use

the message ID and the message

data

to

determine

what the

p

do

next. To receive the message ID

and data, you must provide eno

on

the

error

code

parameter for

the

information.

 

 

 

 

 

 

In

the following example, the bytes available

field

is

checked

to

error occurred. In this case, if an

error occurred, a message is

states

the

message

ID

and

that

the

call

 

to

the

API failed.

 

 

Chapter 4. Common Information across APIs—Advanced (ILE)4-5Example

Page 95
Image 95
IBM Version 4 Error Handling through the Error Code Parameter, Ccsid, Initialize Bytes provided Field Number Parameter