In this installment of APIs by Example, I will demonstrate some of the APIs
that are available to access different types of system information.
Regular APIs, as well as various MI built-in functions, offer a lot of
information in this area. In the API manual, many of the APIs related to
system information are found in the 'Work Management
APIs' category. You can view the APIs in this category at the following link:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/wm1.htm
In the following API example, I have also included a couple of Software
Product APIs, which have their own category. You can read about those APIs
by clicking this link:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/sw1.htm
Finally, the MI built-in functions also provide a wealth of system information.
Many of the 'Materialize' built-ins in general, and the Materialize Machine
Attributes in particular, are a source of system information otherwise not
programmatically available. All built-ins as of release V5R1 are documented here:
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/in...
The so-called built-ins are, in reality, interfaces to corresponding MI functions.
They make MI functions available to all ILE languages. The ILE C/C++ languages
also have their own version of these MI function interfaces, documented in the
'ILE C/C++ MI Library Reference', which is available here:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/books/c0924180.pdf
It is not necessary to reference any service program or binding directory during
compilation to make the built-ins available to the compiler. All of the ILE compilers
have implicit access to the MI built-ins. In fact, the compiler will often replace an
MI built-in reference with an in-line call to the actual MI function to avoid the
overhead connected to an external call.
To hide most of the complexity that's involved in calling the APIs and built-ins
and make the information they provide easily accessible to other programs, I
have created a service program containing procedures that act as wrappers
around the APIs and built-ins. The following procedures are included in the
service program:
GetSysStt() -- Get system state
Returns '1' if the system is currently in
Restricted state and '0' if not.
GetSysVal() -- Get system value
Returns the specified system value.
GetNetAtr() -- Get network attribute
Returns the specified network attribute.
GetRlsLvl() -- Get system release level
Returns the system's current release level.
GetIplDts() -- Get IPL timestamp
Returns the timestamp of the last IPL performed.
GetCumLvl() -- Get cumulative PTF package level
Returns the package ID of the most recent
cumulative PTF package that was applied.
GetPrcGrp() -- Get processor group
Returns the system's processor group.
GetPrcTyp() -- Get processor type
Returns the system's processor type.
GetKeyPos() -- Get panel key position
Returns the current key lock position on the panel.
GetIplTyp() -- Get current IPL type
Returns the current IPL type set on the panel.
To easily let you test the above procedures, I have also included a sample
program that presents some of the system information retrieved by the
procedures in a display window:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
.................................................................
: :
: Last system IPL date and time: 2005-02-16-06.03.25.000000 :
: :
: :
: :
: :
: :
: Bottom :
: F12=Cancel :
: :
:...............................................................:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Press enter to continue the system information retrieval and presentation.
The sample program eventually prompts you to specify a system value of
your choice and then displays the retrieved system value in the display
window:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Display Program Messages
Please enter a system value to retrieve:
Type reply, press Enter.
Reply . . . QSECURITY
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
.................................................................
: :
: System value 'QSECURITY': 30 :
: :
: :
: :
: :
: :
: Bottom :
: F12=Cancel :
: :
:...............................................................:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
This article demonstrates the following APIs:
Retrieve System Value (QWCRSVAL) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qwcrsval...
Retrieve System Status (QWCRSSTS) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qwcrssts...
Retrieve Network Attribute (QWCRNETA) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qwcrneta...
Retrieve Job Information (QUSRJOBI) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qusrjobi...
Retrieve Product Information (QSZRTVPR) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qszrtvpr...
List Program Temporary Fixes (QpzListPTF) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qpzlstfx...
Convert Date and Time Format (QWCCVTDT) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qwccvtdt...
Create User Space (QUSCRTUS) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/quscrtus...
Delete User Space (QUSDLTUS) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qusdltus...
Retrieve Pointer to User Space (QUSPTRUS) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/qusptrus...
Convert Edit Code (QECCVTEC) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/QECCVTEC...
Display Long Text (QUILNGTX) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/quilngtx...
Send Program Message (QMHSNDPM) API:
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/QMHSNDPM.htm
Receive Program Message (QMHRCVPM) API:
http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/apis/QMHRCVPM...
The following MI built-in functions are demonstrated in this article:
Late Bound Edit (_LBEDIT):
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/ED...
Materialize Machine Attributes (_MATMATR1):
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/MA...
The following ILE C function is demonstrated in this article:
Test Bit in String (tstbts):
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c0924180.pdf
You can retrieve the source code for this API example from
http://www.iseriesnetwork.com/noderesources/code/clubtechcode/RtvSystemI... .
The above article was written by Carsten Flensburg. If you have any questions, you
can contact Carsten at mailto:flensburg@novasol.dk .