BAPI for reading CCMS values - abap

I am currently developing a small application which reads actual values from the CCMS Monitoring, but I got a small problem.
I actually use the BAPI BAPI_SYSTEM_MTE_GETPERFCURVAL to read the values from the CCMS environment (e.g CPU_Utilisation).
But for some values this is not working. A collegue told me to use BAPI_SYSTEM_MTE_GETMLCURVAL.
But this one is also not working for all CCMS Items (eg. it is not working for CPU_Utilisation).
Is there a BAPI which can read all CCMS values? It would be great if there was a BAPI which had the same input parameters as the ones above.
PS: (Yes, I know in the near future there will be a new monitoring environment (MAI))
[EDIT]
Hi,
I figured something out.
Each CCMS Object has a type. (performance, logging, alerting)
I know, that the BAPI BAPI_SYSTEM_MTE_GETTIDBYNAME delivers me the parameter TID for the given MTE-OBJECT-NAME tuple. Inside the TID is a field which is called MTCLASS.
Can anybody tell me, where I can find the values for the field MTCLASS so that I can decide whether to use BAPI_SYSTEM_MTE_GETPERFCURVAL or BAPI_SYSTEM_MTE_GETMLCURVAL?

Answering your question from the edited part...
The possible values for the MTCLASS are defined as constants in the include RSALBAPI.
Here comes a fragment of this include with aforementioned constants.
* monitoring tree element (MT): type classes
CONSTANTS:
MT_CLASS_NO_CLASS LIKE ALGLOBTID-MTCLASS VALUE '000',
MT_CLASS_SUMMARY LIKE ALGLOBTID-MTCLASS VALUE '050',
MT_CLASS_MONIOBJECT LIKE ALGLOBTID-MTCLASS VALUE '070',
MT_CLASS_FIRST_MA LIKE ALGLOBTID-MTCLASS VALUE '099',
MT_CLASS_PERFORMANCE LIKE ALGLOBTID-MTCLASS VALUE '100',
MT_CLASS_MSG_CONT LIKE ALGLOBTID-MTCLASS VALUE '101',
MT_CLASS_SINGLE_MSG LIKE ALGLOBTID-MTCLASS VALUE '102',
MT_CLASS_HEARTBEAT LIKE ALGLOBTID-MTCLASS VALUE '103',
MT_CLASS_LONGTEXT LIKE ALGLOBTID-MTCLASS VALUE '110',
MT_CLASS_SHORTTEXT LIKE ALGLOBTID-MTCLASS VALUE '111',
MT_CLASS_VIRTUAL LIKE ALGLOBTID-MTCLASS VALUE '199'.

Related

LabVIEW Inserting/overwriting text into existing string

I was wondering if folks have found a reliable way to inject text into an existing string. Some context, I'm writing data to a string indicator formatted like a table, and I wanted to inject values into so they maintain a specific format, spacing-wise. Writing to a table would definitely be easier, however I am porting a legacy program and wanted to provide familiarity to the end user.
Essentially, I want to do the equivalent of typing into a .txt file with the INSERT function enabled, where it just overwrites the content already in the string. Example below (dashes added to show spacing) of how it is currently looking when I inject the values with hard coded spacing:
Time---value---avg. value---result
60------10---------20---------PASS
120------11---------20---------PASS
180------9---------15---------FAIL
I'd prefer it to look more lined up, like below:
Time---value---avg. value---result
60------10---------20---------PASS
120-----11---------20---------PASS
180-----9--------- 15---------FAIL
Writing my application using LabVIEW 2019
Edit: Header will obviously not change, only each subsequent line where the values can result in entries not looking lined up
What about "Replace Substring" function (https://zone.ni.com/reference/en-XX/help/371361R-01/glang/replace_substring/)? Doesn't it meet your requirements?
The diagram below outputs 01234999990123PASS890123456789. The values of the integer and the word PASS are added replacing characters in the existing string, exactly like overstrike would do.

Getting the values of an /AIF/ERR variant

I did try using the RS_VARIANT_CONTENTS and RS_VARIANT_VALUES_TECH_DATA, it did show the values of the variant except the values of the name space, interface and interface version in which I also need to retrieve. I also searched the VARI* and TVARC tables but I didn't found it there.
I think it has something to do with the program name and screen number. Do you have any ideas or other way that I can retrieve all those values, whether using FM or select?
Thank you.
Some of the parameters in the transaction /AIF/ERR, the ones you are talking about, vary dynamically based on the value chosen in the Application screen field. They are handled by another AIF program, and they are not saved in the program variant, but in the table /AIF/T_ERR_VARS.
You may call the function module /AIF/ERR_VAR_LOAD to load the missing parameters.
Its usage is shown in the subroutine GET_VAR of the program /AIF/ERROR_HANDLING_TRANS (which is the program behind the transaction /AIF/ERR).

Reuse a previously processed value in a column

I hope someone can help me on that as I'm struggling to get it work as expected.
In my DB I have phone numbers with different format (i.e: 15551234, 5551234, +15551234).
So I'm using the following CASE to clean this up and it works great:
CASE
LEFT(DC.PhoneNumber0,1)
WHEN '+' then replace(DC.PhoneNumber0,'+1','')
WHEN 1 then right(DC.PhoneNumber0,len(DC.PhoneNumber0)-1)
ELSE DC.PhoneNumber0
End 'Transformed Number',
Now this return the clean phone number I need to work on (5551234) in the 'Transformed column'
I would like now to use another CASE that retrieve this cleaned number and extract the area code to translate it in an understandable value (i.e.: 201 => US - New Jersey)
So I'm stuck in writing the second CASE.
I tried something like that, but it's NOT working with numbers that are already clean in my DB.
CASE
WHEN right(left(replace(DC.PhoneNumber0,'+',''),4),3) in (201, 1201) then 'US - New Jersey'
WHEN right(left(replace(DC.PhoneNumber0,'+',''),4),3) in (202, 1202) then 'US - Washington D.C.'
Ideally, I would like to reuse, the value that I just transformed in the previous CASE. Is there a way to do it?
Thanks in advance for your help.
You can CREATE FUNCTION containing your initial phone number parse logic and then just reference the function twice. Your DBMS create function syntax should have a clause declaring the function to be NOT VARIANT or DETERMINISTIC so it can be run only once per row regardless how many times you invoke it.

Get Text Symbol Programmatically With ID

Is there any way of programmatically getting the value of a Text Symbol at runtime?
The scenario is that I have a simple report that calls a function module. I receive an exported parameter in variable LV_MSG of type CHAR1. This indicates a certain status message created in the program, for instance F (Fail), X (Match) or E (Error). I currently use a CASE statement to switch on LV_MSG and fill another variable with a short description of the message. These descriptions are maintained as text symbols that I retrieve at compile time with text-MS# where # is the same as the possible returns of LV_MSG, for instance text-MSX has the value "Exact Match Found".
Now it seems to me that the entire CASE statement is unnecessary as I could just assign to my description variable the value of the text symbol with ID 'MS' + LV_MSG (pseudocode, would use CONCATENATE). Now my issue is how I can find a text symbol based on the String representation of its ID at runtime. Is this even possible?
If it is, my code would look cleaner and I wouldn't have to update my actual code when new messages are added in the function module, as I would simply have to add a new text symbol. But would this approach be any faster or would it in fact degrade the report's performance?
Personally, I would probably define a domain and use the fixed values of the domain to represent the values. This way, you would even get around the string concatenation. You can use the function module DD_DOMVALUE_TEXT_GET to easily access the language-dependent text of a domain value.
To access the text elements of a program, use a function module like READ_TEXT_ELEMENTS.
Be aware that generic programming like this will definitely slow down your program. Whether it would make your code look cleaner is in the eye of the beholder - if the values change rarely, I don't see why a simple CASE statement should be inferior to some generic text access.
Hope I understand you correctly but here goes. This is possible with a little trickery, all the text symbols in a report are defined as variables in the program (with the name text-abc where abc is the text ID). So you can use the following:
data: lt_all_text type standard table of textpool with default key,
lsr_text type ref to textpool.
"Load texts - you will only want to do this once
read textpool sy-repid into lt_all_text language sy-langu.
sort lt_all_Text by entry.
"Find a text, the field KEY is the text ID without TEXT-
read table lt_all_text with key entry = i_wanted_text
reference into lsr_text binary search.
If you want the address you can add:
field-symbols: <l_text> type any.
data l_name type string.
data lr_address type ref to data.
concatenate 'TEXT-' lsr_text->key into l_name.
assign (l_name) to <l_text>.
if sy-subrc = 0.
get reference of <l_text> into lr_address.
endif.
As vwegert pointed out this is probably not the best solution, for error handling rather use message classes or exception objects. This is useful in other cases though so now you know how.

Passing multivalue parameter to a subreport

I'm having a problem when working with multivalue parameters between reports.
I have a main report in which I have defined a multivalue paramer, which I use to run a SQL query to populate its dataset. The parameter is used in the WHERE clause in the following way:
WHERE values IN (#parameter)
It's working fine and it retreives the expected data.
Then this main report passes this parameter to a subreport. The parameter is also defined as multivalue in the subreport and, as far as I can see in the parameter's dropdownlist it receives the values in the right way. Something like this: A, B, C
The thing is that the query that populates the subreport's dataset returns nothing.
It also has a WHERE clause defined as in the main report (which is already working)
WHERE values IN (#parameter)
If I run the query manually, hardcoding the values to something like this:
WHERE values IN ('A', 'B', 'C')
it works, but when I try to use the parameter it doesn't. So, somehow it's losing the format or the values in the way.
I tried this solution in the subreport's dataset definition, which was proposed in another thread:
=join(Parameters!<your param name>.Value,",")
But it doesn't work for me, the dataset is still empty.
Any ideas about what I'm missing?
Thanks! :)
This should "just work." Make sure that the Parameter in the subreport is set up as multivalue, and I usually use the exact same query as in the parent report to provide "Available Values."
Check that you are passing the entire parameter to the subreport: In subreport properties on the parent report, the parameter's value should read [#MyParamName] not <<Expr>>. If it reads as the latter, edit the expression and make sure it doesn't have a (0) at the end. but =Parameters!MyParamName.Value is correct, not =Parameters!MyParamName.Value(0)
Just created the report from scratch again and it worked. I must have forgotten something in the middle.
Anyway, just in case somebody needs it, the two parameters, the one in the main report and the one in the subreport , must be defined as multivalue.
Then in your query you should use IN in your WHERE clase, something like this:
WHERE field IN (#parameter)
And nothing else is needed. I didn't need to do the following:
=join(Parameters!<your param name>.Value,",")
It just worked for me
I think I know what you did, as I was drawn here by having the same problem.
The subreports were setup fine, but when entering the parameter binding in the parent report, the Value drop down did not offer my parameter, so I used expression builder to select it. This left the grey << Expr >> marker in the value and would only work when I had only one value selected from the list. When I replaced this with [#MyParam] it worked fine regardless of the number of values selected. When I had a look at the value expression builder had created a bit closer it had =Parameters!MyParam.Value(0). Removing the (0) also fixes it.