Coding for New Function
New function from IBM can cause programs to fail if the programs do not allow for
the handling of a new function.
The example programs in the following topics create a list of all objects that adopt
authority and then process the objects based on their object type. The new func-
tion added is the addition of another object type, *SRVPGM, that can adopt owner
authority.
A general theme of this example is never to assume that the values returned by an
API are static. OS/400 is continually evolving. While the example is based on the
addition of a new object type, this philosophy should be applied to any output of an
API. For example, if an API today can return *YES or *NO, you should discretely
check for these values because *MAYBE might be valid in the future. Similarly, if
your application assumes a particular integer output has a positive nonzero value
(an offset for instance), you should check for a positive nonzero value because
future releases could return a negative value to indicate new function.
Coding for New Function—Example of Incorrect Coding
In this example program, a check is made to determine the object type. This is
shown at .2ð/ on page 9-40. The example program considers only object types of
*SQLPKG or *PGMs. This is because they are the only object types that could
adopt owner authority before Version 2 Release 3. Since that time, a new object
type of *SRVPGM has been introduced. *SRVPGM can adopt owner authority.
Hence, this example program processes *SRVPGM objects as if they were *PGM
objects. The correct coding is shown at .23/ on page 9-47.
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
D\
D\Program Name: PGM1
D\
D\Program Language: ILE RPG
D\
D\Description: This example program demonstrates how a program can
D\ be "broken" by new functions introduced on the AS/4ðð.
D\
D\
D\
D\Header Files Included: QUSGEN - Generic Header of a User Space
D\ (Copied Into Program)
D\ QUSEC - Error Code Parameter
D\ (Copied Into Program)
D\ QSYLOBJP - List Objects API
D\ (Copied Into Program)
D\
D\APIs Used: QUSCRTUS - Create User Space
D\ QSYLOBJP - List Objects That Adopt Owner Authority
D\ QUSROBJD - Retrieve Object Description
D\ QUSPTRUS - Retrieve Pointer to User Space
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
D\
D\ This program demonstrates how a program can be "broken" by
C\ new functions introduced on the AS/4ðð.
D\
9-36 System API Programming V4R1