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