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 specifies two
variable-length records. The replace_rec field contains the length of the variable-
length record (value of 16), the key (value of 4), and the length of the data (value of
1). The replace field contains the data for the replace key. The Reserved field
reserves 3 bytes to force the next record to start on a 4-byte boundary alignment.
The 3 bytes that are reserved are counted as part of the length for the replace
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 error code
parameter or have exceptions signaled by the API to your application program.

Error Handling through the Error Code Parameter

The error code parameter enables a user to have exceptions returned to the
program through the use of the parameter instead of having the exceptions sig-
naled. Some exceptions may be signaled to the caller regardless of the size of the
error code parameter. These exceptions are usually from errors that occur with the
error code parameter itself (that is, message CPF3CF1) or with one of the other
parameters (that is, message CPF9872). In the latter case, message CPF9872 is
always signaled and never returned through the error code parameter because the
API is unable to verify the error code parameter before the exception occurs.
The caller of the API must initialize the error code parameter so that the bytes pro-
vided field is set to the size, in bytes, of the error code parameter. For example,
the error_code_struct structure on page 4-3 sets the size at 116 bytes. To initialize
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 that were allocated for
the parameter:
error_code.ec_fields.Bytes_Provided=sizeof(error_code_struct);
If the bytes provided field is set to a value equal to or greater than 8, the caller
wants all exceptions returned through the error code parameter. The API fills in all
of the message information up to the size of the error code parameter.
Error Determination—Example:
On the return from the call to the API, verify
whether or not an error occurred. If an error occurred, the bytes available field is
set to something other than zero. If the bytes available field is not zero, you can
use the message ID and the message data to determine what the program should
do next. To receive the message ID and data, you must provide enough storage
on the error code parameter for the information.
In the following example, the bytes available field is checked to determine if an
error occurred. In this case, if an error occurred, a message is printed, which
states the message ID and that the call to the API failed.
Chapter 4. Common Information across APIs—Advanced (ILE) Example 4-5