SM7.1 – How to get the level of CAT ID from Multilevel Categorization
There was a request in my site asking to display the level of the category id assigned to ITSM/CHARM documents in reference of Multilevel Categorization hierarchy (MC). Unfortunately, SM 7.1 stores them as an unique GUID in a single field though ITSM webui is displaying separated fields for each different category level. Methods in CL_CRM_ML_CATEGORY_UTIL didn’t give any result with the CAT ID & ASP ID from CRM_ORDER_READ. which made me confused but figured out soon.
If you cannot get result values from CL_CRM_ML_CATEGORY_UTIL~GET_CATEGORYFIRST with 1Order GUID, you might need to have a look at below codes
Here is the logic that worked for me on the environment of Solution Manager 7.1 SP 13 + BBPCRM 7.01 SP13.
First, You need to get SUBJECT data either from the function module ‘ CRM_ORDER_READ’ or from the CRM*READ*. Usually, will get two lines in the subject tab, one for the header, the other for the item and schema GUID and category GUID can be read from table CRMV_ERMS_CAT_CA with ASP_ID & CAT_ID from subject data. One thing need to remember in selecting data from the table is to make sure whether the data entry status is ‘R'(released) and the language key is correct because multiple schema can be assigned but only one of them is to be released .
SELECT SINGLE ASP_GUID CAT_GUID
INTO (LV_ASP_GUID, LV_CAT_GUID)
WHERE ASP_ID = LS_SUBJECT–ASP_ID
AND CAT_ID = LS_SUBJECT–CAT_ID
AND ASP_STATE = ‘R’
AND LANG = SY–LANGU.
Now it’s time to use utility class CL_CRM_ML_CATEGORY_UTIL for MC
CALL METHOD CL_CRM_ML_CATEGORY_UTIL=>GET_SELECTED_CATEGORY_TREE
IV_SELECTED_CAT_GUID = LV_CAT_GUID
IV_SCHEMA_GUID = LV_ASP_GUID
* ET_CAT_TREE =
EV_SELECTED_LEVEL = LV_SELECTED_LEVEL.
Now you will get the category level of category id in your ITSM/CHARM documents.
In certain circumstance, probably depending on configuration or on package kind, you cannot use order guid directly in CL_CRM_ML_CATEGORY_UTIL and It needs to get ASP GUID & CAT GUID from table CRMV_ERMS_CAT_CA before use CL_CRM_ML_CATEGORY_UTIL.
Hope this article helps you guys .