Awhile back, along the the time that SDN was just starting up I posted and asked and pleaded for help with this topic. The question, "How do I read the MTE Class values using ABAP"?
Well since then I've managed to figure it out and I want to share that with you now. Why should I share this tasty little tidbit? Well why not, there are plenty of OpenSource and Commerical tools out there already for this, I'm just going to show you how to do it with ABAP and especially with BSP.
I started first by reducing the number of choices and options in a monitor set. I wanted to try and get to a point where it was very, very clear what I needed to read/access for the data. So I created a new Monitor set for my test purposes. I called it "Craigs_Fight", a bit much but come on I've been at this for awhile without help . I then defined it like this...
The result once activated was simple and easy. I figured I had it, I had the basic info for a single MTE class and now how to get that 1% value of the thing?
So first things first, with your activated Monitor set, click on the CPU_Utilization line and choose the button at the top of the screen "Properties" you'll need to find the exact name of the MTE Class and value you want to read.
Then it's off to some fun with function modules. At which point I will now tell you that I do not know how long these function modules will work because occasionally SAP tends to change things or turn them off.
Ok, we have our value and the first step is of course to find the MTE TID value for the MTE Class/Value. We can do this by using the function module in transaction SE37 "SALR_MTE_GET_TID_BY_NAME" which takes the input value "WA2\\ciwa2_WA2_19\\...\\CPU\\CPU_Utilization" be sure to mark the "Upper/Lower Case" as this is case sensitive. Once we run this, the resulting output is a table:
Now you need to do the whole CTRL-Y and copy the values from this table, then call the function module "SALR_MTE_GET_TREE" and give the input table the values you just copied. Again watch out for case sensitive! From this function module we get the resulting value of the available MTE sub classes. So find the one you want, in this case CPU_Utilization and copy the values for the TID just like before.
Now call the function module "SALR_MTE_PERF_READ_CUR_VAL" and give the input values (the ones you just copied). From here you get the "CURRENT_VALUE", so you now have the current value of your MTE class for this system. The "CURRENT_VALUE" is a table that is returned and for our purposes we just want to read 4 of the fields.
- LASTPERVAL - Actual Last
- AVG15PVAL - Avg 15 min
- AVG05PVAL - Avg 5 Min
- AVG01PVAL - Avg 1 Min
Wow such a lot of work just to get a single value that could have been achieved with another function module called "GET_CPU_ALL", however like I pointed out we have several systems so with some creative searching you'll find the function modules that will return back a table of values for multiple TID's. Oh by the way if you'd like a good example of "GET_CPU_ALL" you should check out this article by By Siarhei Ulasenka.
Now as most people on here may have noticed already, I am a BSP Freak, I got a t-shirt and everything! So here we go on making a small BSP page to read the data we just struggled to find, and since I'm so happy to finally have the solution I'll provide the code for reading multiple values.
style="border:thin inset;background:lightgrey;background-color:lightgrey;width:400px">\ CURRENT_VALUE\ TYPE\ ALPERFVAL\ Alert: Performance MT specific value part
CURRENT_VALUES\ TYPE\ ALTIDPACVATBL\ MoniArch: TID plus Perf. Current Values plus RC
wtab\ TYPE\ ALTIDPACVA\ MoniArch: TID plus Perf. Current Values plus RC
You'll notice I use a ZCSC_TIDS table, this is basically just a local copy of the TID table.
style="border:thin inset;background:lightgrey;background-color:lightgrey;width:400px">\ MTSYSID\ SYSYSID\ CHAR\ 8\ 0\ Name of SAP R/3 System
MTMCNAME\ ALMCNAME\ CHAR\ 40\ 0\ Alert: Name of Monitoring Context
MTNUMRANGE\ ALTIDNUMRG\ CHAR\ 3\ 0\ Alert: monitoring type number range (perm., temp, ...)
MTUID\ ALTIDUID\ CHAR\ 10\ 0\ ALert: Unique Identifier for Monitoring Types (used in TID)
MTCLASS\ ALTIDMTCL\ CHAR\ 3\ 0\ Alert: monitoring type class (perf., single msg.,...)
MTINDEX\ ALTIDINDEX\ CHAR\ 10\ 0\ Alert: internal handle for TID
EXTINDEX\ ALTIDINDEX\ CHAR\ 10\ 0\ Alert: internal handle for TID
The ZGET_MTE_CURVALUES is a function I created. This function is basically just a copy of the "SALR_MTE_PERF_READ_CUR_VAL_TBL" and remote-enabled since I was calling the function remotely for our tests.
Again there is no telling when SAP will change all of this so use it at your own risk
So what do we have for resulting output?
All in all not a bad little exercise I would say. As you play around with it I'm sure you'll discover several possible uses for this type of functionality.
Updated: Alexander just gave me a link to a SAP document, bummer I didn't have it sooner :-)
Including External System Management Programs in the CCMS Monitoring Architecture this of course all comes from a thread which can be found here