All OS/400 objects have a common set of attributes regardless of object type. You can display many of these attributes using the Display Object Description (DSPOBJD) command, yet very few of the attributes can be changed by the Change Object Description (CHGOBJD) command. In fact, the only things you can change are the object’s text description and its days used count.
To alleviate this shortcoming, this week’s API by Example offers a command interface to the Change Object Description (QLICOBJD) API. This API is capable of changing a number of object attributes that are not accessible otherwise.
The following command prompt documents the attributes that can be changed using the CHGOBJATR command:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Change Object Attributes (CHGOBJATR)
Type choices, press Enter.
Object . . . . . . . . . . . . Name
Library . . . . . . . . . . *LIBL Name, *LIBL, *CURLIB...
Object type . . . . . . . . . *ALRTBL, *BNDDIR, *CFGL..
Source file . . . . . . . . . *SAME Name, *SAME, *BLANK
Library . . . . . . . . . . Name
Source member . . . . . . . . *SAME Name, *SAME, *BLANK
Source file last changed:
Date . . . . . . . . . . . . *SAME Date, *SAME, *CURRENT
Time . . . . . . . . . . . . Time, *CURRENT
Allow change by program . . . *SAME *NO, *YES, *SAME
User-defined attribute . . . . *SAME Character value, *SAME...
Text 'description' . . . . . . *SAME
Days used count . . . . . . . *SAME *SAME, *RESET
Last used date . . . . . . . . *SAME *SAME, *UPDATE
Changed date and time stamp . *SAME *SAME, *CURRENT
Reset member's days used count *NONE Name, *NONE
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
The individual attributes are explained in detail in the help panel group that is included, but of particular interest to this command is the ‘Allow change by program’ attribute. In the event that this is set to *NO, the QLICOBJD API will not be permitted to perform any further attribute changes.
Once you enter an object name and object type and press enter, the command’s prompt override program (POP) will retrieve the specified object’s current attribute values. The POP source member CBX135O can be used as a template, in case you want to add this feature to your own commands. To make a POP work, two things must be done:
a) Specify the POP on the CRTCMD command’s PMTOVRPGM keyword when creating the command –- as in the following example:
CrtCmd Cmd( CHGOBJATR )
Pgm( CBX135 )
SrcMbr( CBX135X )
VldCkr( CBX135V )
HlpPnlGrp( CBX135H )
HlpId( *CMD )
PmtOvrPgm( CBX135O )
b) For each command keyword that is used to identify the entity from which the prompt override values are retrieved, you must specify KEYPARM( *YES ):
Parm OBJ Q0001
Min( 1 )
Choice( *NONE )
KeyParm( *YES )
Prompt( 'Object' )
Every key parameter is passed as a parameter to the POP. All in all, the following parameters will be passed:
Command name INPUT Qualified command name
Key parameter 1 INPUT Key parameter 1 identifying the
entity for which to retrieve
prompt values.
Key parameter n INPUT Key parameter n. One parameter
is passed for every specified
key parameter.
Command string OUTPUT The formatted command prompt
string returning prompt values.
More details on the prompt override program concept can be found in the CL Programming manual –- from page 320 to 326. You can download this manual from the following link:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/books/c4157215.pdf
The selective prompting instructions used to compose the command string are described in the same manual, from page 168 to 171.
Apart from the above attributes, the QLICOBJD API also is capable of changing the following attributes:
-- Object control level -- Licensed program -- Program temporary fix (PTF) -- Authorized program analysis report (APAR) -- Product option load ID -- Product option ID -- Component ID
Please refer to the QLICOBJD API documentation (available at the link below) for further information about these attributes. If you need to be able to change some or all of these in your shop, it should be easy to adapt the CHGOBJATR command to support these attributes, too.
Here’s an example of changing an object's user-defined attribute:
CHGOBJATR OBJ(CBX135) OBJTYPE(*PGM) USRDFNATR(B_09.02.01)
The new attribute setting takes effect immediately and can be displayed by running the DSPOBJD ... DETAIL(*FULL) command, as follows:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Display Object Description - Full
Library 1 of 1
Object . . . . . . . : CBX135 Attribute . . . . . : RPGLE
Library . . . . . : QGPL Owner . . . . . . . : GARY
Library ASP device . : *SYSBAS Primary group . . . : *NONE
Type . . . . . . . . : *PGM
User-defined information:
Attribute . . . . . . . . . : B_09.02.01
Text . . . . . . . . . . . . : Change Object Attributes - CPP
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
The CHGOBJATR command includes the following sources:
CBX135 –- Command processing program.
CBX135X -- Command definition source member.
CBX135O –- Command prompt override program.
CBX135V –- Command validity checking program.
CBX135H -- Command help text panel group.
Compilation instructions are found in the source headers.
This article demonstrates the following APIs:
Change Object Description (QLICOBJD) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qlicobjd.htm
Retrieve Object Description (QUSROBJD) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qusrobjd.htm
Normal End (CEETREC) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/CEETREC.htm
Convert Type (QLICVTTP) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qlicvttp.htm
Retrieve Member Description (QUSRMBRD) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qusrmbrd.htm
Send Program Message (QMHSNDPM) API:
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/QMHSNDPM.htm
Retrieve Message (QMHRTVM) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/QMHRTVM.htm
You can retrieve the source code for this API example from http://www.pentontech.com/IBMContent/Documents/article/50892_19_ChgObjAtr.zip.