Skip to Content

System Status with PHP and XMI Part 1

Craig PHP / HowTo: Your system status (RZ20) and covered accessing the system status using BSPs and then reusing the same interface with PHP.

This weblog will demonstrate accessing the CCMS data using the XMI interface with PHP. There is absolutely no reason why a fully featured external monitoring system could not be created in PHP.

The example pulls the data from the monitor template to show the CPU utilizition, 5 minute load and idle time.

Steps There are only 3 essential RFC calls to make in order to retrieve the data.


The data being accessed is from the XAL interface. This and all other BAPIs are covered in this document. To get the exact values I needed and determine the required calls I essentially called every BAPI. This is where saprfc_test.php once again proved its incredible usefulness. I cannot imagine having to code the interface params by hand.

The call to BAPI_SYSTEM_MT_GETPERFDATA requires that you have the monitor template IDs for the data you want to retrieve. In the best Blue Peter fashion (Brits will know what I mean), this is one I prepared earlier to get the MTID numbers. If there is interest I will create a Weblog covering those details.

Source Code
There really is not much to this one at all. Three simple RFC calls and data pulled from the returned arrays.

‘; echo “This is a very basic output to demonstrate the functionality of the interface

“; $count = 0; while (list($k,$v) = each($CURRENT_VALUES)) { echo $descr[$count++].’ = ‘.$v[‘ALRELEVVAL’].”
“; } echo “”; $fce = saprfc_function_discover($rfc,”BAPI_XMI_LOGOFF”); if (! $fce ) { echo “Discovering interface of function module failed”; exit; } saprfc_import ($fce,”INTERFACE”,”XAL”); $rfc_rc = saprfc_call_and_receive ($fce); if ($rfc_rc != SAPRFC_OK) { if ($rfc == SAPRFC_EXCEPTION ) echo (“Exception raised: “.saprfc_exception($fce)); else echo (saprfc_error($fce)); exit; } $RETURN = saprfc_export ($fce,”RETURN”); saprfc_function_free($fce); saprfc_close($rfc); ?>

Part 2
For part 2 the data will be returned as an XML document. This data will then be used by a widget in OS X Tiger. For those unfamiliar with widgets, they are small applications that provide data to a user. Watching the system status is an ideal application for widgets.

You must be Logged on to comment or reply to a post.