Using the Error Code Parameter

The error code parameter provides a way for you to determine if th tered any errors.

The examples in this topic present a program used for creating a use

Using the Error Code

Parameter—Example

of Incorrect

Coding

 

 

 

 

 

 

The

common

error

shown in the following example is the use of the erro

structure to indicate to the API not to send exception messages for

Additionally,

the

example does not examine the error code structure to

the

API

call

was

successful

or

not. To

demonstrate

the

improper use of

code

 

structure,

an incorrect value is used on the replace parameter

QUSCRTUS API. The

replace

parameter

is

a required

parameter. The

code

error

(*XXXXXXX)

is shown at.2/locationinthe incorrect and correct coding

(pages 9-3 and 9-4, respectively).

 

 

 

 

 

 

Both

the

incorrect and

correct.1/

oncodingpage

(9-3 .1/and on page

9-3)

show

 

the program monitoring for any

error from the call to the API. However,

program

does

not

examine

the

bytes

available field

after

calling

the

API.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Because of the error on the replace parameter, the requested user created. The calling program, however, is not aware.3/ofon thispage(shown at 9-3).

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

\

\Program Name: PGM1

\

\Program Language: RPG

\

\Description: This sample program illustrates the incorr￿ect

\way of using the error code parameter.

\

\Header Files Included: QUSEC - Error Code Parameter

\

\APIs Used: QUSCRTUS - Create User Space

\

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

\BRING IN THE ERROR STRUCTURE FROM QSYSINC I/COPY QSYSINC/QRPGSRC,QUSEC

\\

ISPCNAM

DS

 

 

 

I I

'SPCNAME

'

1

1ð SPC

I I

'PAM

'

11

2ð LIB

\\ OTHER ASSORTED VARIABLES

IDS

I I

2ððð

B

1

4ðSIZ

I

 

B

5

8ðSTART

I I

X'ðð'

 

9

9 INTVAL

\

 

 

 

 

\Initialize the bytes provided field (QUSBNDB) of the erro￿r code

\structure. Languages such as RPG and CL tend to initialize the bytes

\provided field to blanks, which when passed to an API is vi￿ewed as a

\very large (and incorrect) binary value. If you receive CPF3CF1 when

9-2System API Programming V4R1

Page 208
Image 208
IBM Version 4 manual Using the Error Code Parameter, Xxxxxxx, Pages 9-3 and 9-4, respectively Both Incorrect Correct