C ENDIF
Cᑍ
Cᑍ Delete the user space called APIUG1 in library QGPL.
Cᑍ
C CALL 'QUSDLTUS'
C PARM USERSP
C PARM QUSBN
Cᑍ See if any errors were returned in the error code parameter.
C EXSR ERRCOD
Cᑍ
C SETON LR
C RETRN
Cᑍ
Cᑍ End of MAINLINE
Cᑍ
Cᑍ Subroutine to handle errors returned in the error code
Cᑍ parameter.
Cᑍ
C ERRCOD BEGSR
C QUSBNC IFGT
Cᑍ
Cᑍ Process errors returned from the API.
Cᑍ
C END
C ENDSR
Using Offsets in a User Space—Example of Correct Coding
The following example program has code in it that compensates for the API offset
convention of that starts at 0. The code adds 1 to the starting position (STRPOS)
offset. This is shown at 19 on page 9-34.
Iᑍ
IᑍProgram Name: APIUG2
Iᑍ
IᑍProgramming Language: RPG
Iᑍ
IᑍDescription: This sample program illustrates the correct
Iᑍ way of using offsets in user space.
Iᑍ
IᑍHeader Files Included: QUSGEN - Generic Header of a User Space
Iᑍ QUSEC - Error Code Parameter
Iᑍ (Copied into Program)
Iᑍ QUSLOBJ - List Objects API
Iᑍ
IᑍAPIs Used: QUSCRTUS - Create User Space
Iᑍ QUSLOBJ - List Objects
Iᑍ QUSRTVUS - Retrieve User Space
Iᑍ QUSDLTUS - Delete User Space
Iᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Iᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Iᑍ
Iᑍ Generic Header of a User Space Include
Iᑍ
I/COPY QSYSINC/QRPGSRC,QUSGEN
Iᑍ
Iᑍ Error Code Parameter Include for the APIs
Iᑍ
Chapter 9. Common API Programming Errors 9-31