\calling an API, the bytes provided field should be the fir￿st field

\you examine as part of problem determination.

C

Z-ADD16

QUSBNB

.1/

 

\

 

 

 

\ CREATE THE SPACE TO HOLD THE DATA

 

 

C

CALL 'QUSCRTUS'

 

C

PARM

SPCNAM

 

C

PARM 'EXT_ATTR'EXTATR 1ð

 

C

PARM

SIZ

 

C

PARM

INTVAL

 

C

PARM '\ALL

'PUBAUT 1ð

 

C

PARM 'NO TEXT 'TXTDSC 5ð

 

C

PARM '\XXXXXXX'REPLAC 1ð

.2/

C

PARM

QUSBN

 

\\Program does not check the error code parameter .3/

CSETONLR

Using the Error Code Parameter—Example of Correct Coding

You can add code to help you discover what errors may be in a following example program, code has been added to monitor error infor passed back in the error code parameter (QUSBN). This.4/codeon is show page 9-4. The code.4/ athas been added to check the error code para any messages and to display the exception identifier to the user found. The incorrectly coded program does no checking for the error eter (shown.3/aton page 9-3).

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

\

\Program Name: PGM2

\

\Program Language: RPG

\

\Description: This sample program illustrates the correc￿t

\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

SPC

I

I

'QTEMP

'

11

LIB

\\ OTHER ASSORTED VARIABLES

IDS

I I

2ððð

B

1

4ðSIZ

I

 

B

5

8ðSTART

I I

X'ðð'

 

9

9 INTVAL

\

 

 

 

 

C

Z-ADD16

QUSBNB

.1/

\

 

 

 

 

 

 

Chapter

9. Common API Programming Errors 9-3

Page 209
Image 209
IBM Version 4 manual Using the Error Code Parameter-Example of Correct Coding, Call Quscrtus Parm Spcnam, Csetonlr