Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
craigcmehil
Community Manager
Community Manager
0 Kudos

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.

So what are MTE classes? Well those are the classes associated with RZ20, RZ21, RZ23N. It's all the stuff to do with the CCMS alerts. If you go into your system and enter the RZ20 transaction you come up with several predefined SAP monitor sets. Now I don't want to go through the process of how to set up monitor sets and CCMS itself because that is a process in itself. So hopefully you understand what this is before we move further on.

Now the idea is simple here, you have a monitor set and you have "SAPOSCOL" running on your SAP system (see transaction ST06) so therefore your server as well as the system itself is sending data to the CCMS.  If you open one of the monitor sets you'll see the data and how it looks. Well if you are like me and dealing with more than a couple of systems this transaction is not really the best in the world for visiblity and use. Even if you define your own custom monitor sets.  It just doesn't work that well with the rest of the things I use on a daily basis.

With that being said I set about the process of trying to read those data values and display them in a different way inside of a report or webpage. Well if you saw the thread that I posted above you can see I've been at this awhile, and not just here at SDN trying to find an answer.

I found other programs and "packages" that will do this for me but by this time it was a personal matter between me and CCMS. I was determined to figure this out and accomplish my goal.


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 image 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.

Page Attributes
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

Page Layout

\

OnInputProcessing

\

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

13 Comments