Reading the hierachy level in Multi-level Categorization
Multi-level Categorization is a kind of hierarchical categories which can be used in the business transaction for classification purposes. For example, in the service order, we can categorize the defect, reason, solutions into many hierarchical categories. One or more than one can be selected easily from the hierarchical tree in the service order header or item.
Multilevel categorization is available in varying scopes for the following applications:
- Service orders
- Service order templates
- In-house repair orders
- Case management
- Interaction record
In some cases if we need to know which level in the category is filled , then we need to calculate the node level which is filled and based on that we can determine whether the node level which we have to look for is filled or not. For e.g. in defect there are L1->L2->L3->L4->L5 , then if we need to find out if L5 is filled or not and if only level L3 is filled then the output that we would get is level 3 and we sure that L5 is not filled. In some business scenario we need to determine if a particular level is filled ( Level has to be filled mandatorily in the transaction). If the level is not filled we need to raise an error message. So the blog below would help to calcuate the level in a category. Using the APIs in the code below , you can twist and tweak as per your requirement.
data: lr_aspect type ref to if_crm_erms_catego_aspect, lr_category type ref to if_crm_erms_catego_category, lv_ref_guid type guid_16 value '0050560600AD1ED2B8E18732B52E5D75', lv_asp_guid type crm_erms_cat_guid, lv_cat_guid type crm_erms_cat_guid, lv_sel_level type int4, ls_cat type crmt_erms_cat_ca_buf. call method cl_crm_ml_category_util=>get_categoryfirst exporting iv_ref_guid = lv_ref_guid iv_ref_kind = 'A' * iv_catalog_type = 'C'"ORDER_READ->ET_SUBJECT->CAT_ID' importing er_aspect = lr_aspect er_category = lr_category. * get aspect guid call method lr_aspect->get_asp_guid receiving rv_asp_guid = lv_asp_guid. * get category guid call method lr_category->get_details importing ev_cat = ls_cat. lv_cat_guid = ls_cat-cat_guid. cl_crm_ml_category_util=>get_selected_category_tree( exporting iv_selected_cat_guid = lv_cat_guid " Selected Category GUID iv_schema_guid = lv_asp_guid " Schema GUID importing ev_selected_level = lv_sel_level " Selected Category Level * ev_parent_cat_guid = " Parent Category GUID * ev_parent_cat_id = " Parent Category ID * ev_parent_level = " Parent Category level ).
The lv_sel_level would give you the level details. Based on business sceanrio , we can add validations .